[Pkg-javascript-commits] [node-os-tmpdir] 01/12: Imported Upstream version 1.0.1

Ross Gammon ross-guest at moszumanska.debian.org
Fri Aug 21 07:14:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

ross-guest pushed a commit to branch master
in repository node-os-tmpdir.

commit 1adb430e5c0b551ee8bf96e8d88e64050bff55fe
Author: Ross Gammon <rossgammon at mail.dk>
Date:   Wed Aug 19 22:43:43 2015 +0200

    Imported Upstream version 1.0.1
---
 .editorconfig  | 15 +++++++++++++++
 .gitattributes |  1 +
 .gitignore     |  1 +
 .jshintrc      | 12 ++++++++++++
 .travis.yml    |  6 ++++++
 index.js       | 25 +++++++++++++++++++++++++
 license        | 21 +++++++++++++++++++++
 package.json   | 40 ++++++++++++++++++++++++++++++++++++++++
 readme.md      | 36 ++++++++++++++++++++++++++++++++++++
 test.js        | 45 +++++++++++++++++++++++++++++++++++++++++++++
 10 files changed, 202 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..8f9d77e
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..9fe1be2
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,12 @@
+{
+	"node": true,
+	"esnext": true,
+	"bitwise": true,
+	"curly": true,
+	"immed": true,
+	"newcap": true,
+	"noarg": true,
+	"undef": true,
+	"unused": "vars",
+	"strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..dedfc07
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+sudo: false
+language: node_js
+node_js:
+  - 'iojs'
+  - '0.12'
+  - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..52d90bf
--- /dev/null
+++ b/index.js
@@ -0,0 +1,25 @@
+'use strict';
+var isWindows = process.platform === 'win32';
+var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
+
+// https://github.com/nodejs/io.js/blob/3e7a14381497a3b73dda68d05b5130563cdab420/lib/os.js#L25-L43
+module.exports = function () {
+	var path;
+
+	if (isWindows) {
+		path = process.env.TEMP ||
+			process.env.TMP ||
+			(process.env.SystemRoot || process.env.windir) + '\\temp';
+	} else {
+		path = process.env.TMPDIR ||
+			process.env.TMP ||
+			process.env.TEMP ||
+			'/tmp';
+	}
+
+	if (trailingSlashRe.test(path)) {
+		path = path.slice(0, -1);
+	}
+
+	return path;
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..d8501b8
--- /dev/null
+++ b/package.json
@@ -0,0 +1,40 @@
+{
+  "name": "os-tmpdir",
+  "version": "1.0.1",
+  "description": "Node.js os.tmpdir() ponyfill",
+  "license": "MIT",
+  "repository": "sindresorhus/os-tmpdir",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "node test.js"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "built-in",
+    "core",
+    "ponyfill",
+    "polyfill",
+    "shim",
+    "os",
+    "tmpdir",
+    "tempdir",
+    "tmp",
+    "temp",
+    "dir",
+    "directory",
+    "env",
+    "environment"
+  ],
+  "devDependencies": {
+    "ava": "0.0.4"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..54d4c6e
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,36 @@
+# os-tmpdir [![Build Status](https://travis-ci.org/sindresorhus/os-tmpdir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-tmpdir)
+
+> Node.js [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir) ponyfill
+
+> Ponyfill: A polyfill that doesn't overwrite the native method
+
+Use this instead of `require('os').tmpdir()` to get a consistent behaviour on different Node.js versions (even 0.8).
+
+*This is actually taken from io.js 2.0.2 as it contains some fixes that haven't bubbled up to Node.js yet.*
+
+
+## Install
+
+```
+$ npm install --save os-tmpdir
+```
+
+
+## Usage
+
+```js
+var osTmpdir = require('os-tmpdir');
+
+osTmpdir();
+//=> /var/folders/m3/5574nnhn0yj488ccryqr7tc80000gn/T
+```
+
+
+## API
+
+See the [`os.tmpdir()` docs](https://nodejs.org/api/os.html#os_os_tmpdir).
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..cc4584e
--- /dev/null
+++ b/test.js
@@ -0,0 +1,45 @@
+'use strict';
+var assert = require('assert');
+var test = require('ava');
+var osTmpdir = require('./');
+var os = {tmpdir: osTmpdir};
+
+test(function (t) {
+	// https://github.com/nodejs/io.js/blob/3e7a14381497a3b73dda68d05b5130563cdab420/test/parallel/test-os.js#L6-L38
+	process.env.TMPDIR = '/tmpdir';
+	process.env.TMP = '/tmp';
+	process.env.TEMP = '/temp';
+
+	if (process.platform === 'win32') {
+		assert.equal(os.tmpdir(), '/temp');
+		process.env.TEMP = '';
+		assert.equal(os.tmpdir(), '/tmp');
+		process.env.TMP = '';
+		var expected = (process.env.SystemRoot || process.env.windir) + '\\temp';
+		assert.equal(os.tmpdir(), expected);
+		process.env.TEMP = '\\temp\\';
+		assert.equal(os.tmpdir(), '\\temp');
+		process.env.TEMP = '\\tmpdir/';
+		assert.equal(os.tmpdir(), '\\tmpdir/');
+		process.env.TEMP = '\\';
+		assert.equal(os.tmpdir(), '\\');
+		process.env.TEMP = 'C:\\';
+		assert.equal(os.tmpdir(), 'C:\\');
+	} else {
+		assert.equal(os.tmpdir(), '/tmpdir');
+		process.env.TMPDIR = '';
+		assert.equal(os.tmpdir(), '/tmp');
+		process.env.TMP = '';
+		assert.equal(os.tmpdir(), '/temp');
+		process.env.TEMP = '';
+		assert.equal(os.tmpdir(), '/tmp');
+		process.env.TMPDIR = '/tmpdir/';
+		assert.equal(os.tmpdir(), '/tmpdir');
+		process.env.TMPDIR = '/tmpdir\\';
+		assert.equal(os.tmpdir(), '/tmpdir\\');
+		process.env.TMPDIR = '/';
+		assert.equal(os.tmpdir(), '/');
+	}
+
+	t.end();
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-os-tmpdir.git



More information about the Pkg-javascript-commits mailing list