Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-06-18 04:52:41 +0400
committerisaacs <i@izs.me>2012-06-18 04:52:41 +0400
commitaea75e8f4a00e7a32026a452f2299e4dfa3d444f (patch)
tree826507625d99cd3907179fe274b2a696ac01f9b7 /node_modules/osenv
parenta68b5e0f556ee73ea190a97b7d921471fd8bdf23 (diff)
upgrade osenv to 0.0.3
Diffstat (limited to 'node_modules/osenv')
-rw-r--r--node_modules/osenv/README.md11
-rw-r--r--node_modules/osenv/osenv.js11
-rw-r--r--node_modules/osenv/package.json8
-rw-r--r--node_modules/osenv/test/unix.js21
-rw-r--r--node_modules/osenv/test/windows.js20
5 files changed, 65 insertions, 6 deletions
diff --git a/node_modules/osenv/README.md b/node_modules/osenv/README.md
index c5975df5b..08fd90023 100644
--- a/node_modules/osenv/README.md
+++ b/node_modules/osenv/README.md
@@ -50,3 +50,14 @@ No place like it.
An array of the places that the operating system will search for
executables.
+
+## osenv.editor()
+
+Return the executable name of the editor program. This uses the EDITOR
+and VISUAL environment variables, and falls back to `vi` on Unix, or
+`notepad.exe` on Windows.
+
+## osenv.shell()
+
+The SHELL on Unix, which Windows calls the ComSpec. Defaults to 'bash'
+or 'cmd'.
diff --git a/node_modules/osenv/osenv.js b/node_modules/osenv/osenv.js
index f236b5851..e3367a774 100644
--- a/node_modules/osenv/osenv.js
+++ b/node_modules/osenv/osenv.js
@@ -1,5 +1,4 @@
var isWindows = process.platform === 'win32'
-console.error('isWindows = %j', isWindows, process.platform)
var windir = isWindows ? process.env.windir || 'C:\\Windows' : null
var path = require('path')
var exec = require('child_process').exec
@@ -69,3 +68,13 @@ memo('path', function () {
process.env.path).split(isWindows ? ';' : ':')
})
+memo('editor', function () {
+ return process.env.EDITOR ||
+ process.env.VISUAL ||
+ (isWindows ? 'notepad.exe' : 'vi')
+})
+
+memo('shell', function () {
+ return isWindows ? process.env.ComSpec || 'cmd'
+ : process.env.SHELL || 'bash'
+})
diff --git a/node_modules/osenv/package.json b/node_modules/osenv/package.json
index df26c6711..0c01cc815 100644
--- a/node_modules/osenv/package.json
+++ b/node_modules/osenv/package.json
@@ -1,6 +1,6 @@
{
"name": "osenv",
- "version": "0.0.1",
+ "version": "0.0.3",
"main": "osenv.js",
"directories": {
"test": "test"
@@ -32,7 +32,7 @@
},
"license": "BSD",
"description": "Look up environment settings specific to different operating systems",
- "readme": "# osenv\n\nLook up environment settings specific to different operating systems.\n\n## Usage\n\n```javascript\nvar osenv = require('osenv')\nvar path = osenv.path()\nvar user = osenv.user()\n// etc.\n\n// Some things are not reliably in the env, and have a fallback command:\nvar h = osenv.hostname(function (er, hostname) {\n h = hostname\n})\n// This will still cause it to be memoized, so calling osenv.hostname()\n// is now an immediate operation.\n\n// You can always send a cb, which will get called in the nextTick\n// if it's been memoized, or wait for the fallback data if it wasn't\n// found in the environment.\nosenv.hostname(function (er, hostname) {\n if (er) console.error('error looking up hostname')\n else console.log('this machine calls itself %s', hostname)\n})\n```\n\n## osenv.hostname()\n\nThe machine name. Calls `hostname` if not found.\n\n## osenv.user()\n\nThe currently logged-in user. Calls `whoami` if not found.\n\n## osenv.prompt()\n\nEither PS1 on unix, or PROMPT on Windows.\n\n## osenv.tmpdir()\n\nThe place where temporary files should be created.\n\n## osenv.home()\n\nNo place like it.\n\n## osenv.path()\n\nAn array of the places that the operating system will search for\nexecutables.\n",
- "_id": "osenv@0.0.1",
- "_from": "osenv"
+ "readme": "# osenv\n\nLook up environment settings specific to different operating systems.\n\n## Usage\n\n```javascript\nvar osenv = require('osenv')\nvar path = osenv.path()\nvar user = osenv.user()\n// etc.\n\n// Some things are not reliably in the env, and have a fallback command:\nvar h = osenv.hostname(function (er, hostname) {\n h = hostname\n})\n// This will still cause it to be memoized, so calling osenv.hostname()\n// is now an immediate operation.\n\n// You can always send a cb, which will get called in the nextTick\n// if it's been memoized, or wait for the fallback data if it wasn't\n// found in the environment.\nosenv.hostname(function (er, hostname) {\n if (er) console.error('error looking up hostname')\n else console.log('this machine calls itself %s', hostname)\n})\n```\n\n## osenv.hostname()\n\nThe machine name. Calls `hostname` if not found.\n\n## osenv.user()\n\nThe currently logged-in user. Calls `whoami` if not found.\n\n## osenv.prompt()\n\nEither PS1 on unix, or PROMPT on Windows.\n\n## osenv.tmpdir()\n\nThe place where temporary files should be created.\n\n## osenv.home()\n\nNo place like it.\n\n## osenv.path()\n\nAn array of the places that the operating system will search for\nexecutables.\n\n## osenv.editor() \n\nReturn the executable name of the editor program. This uses the EDITOR\nand VISUAL environment variables, and falls back to `vi` on Unix, or\n`notepad.exe` on Windows.\n\n## osenv.shell()\n\nThe SHELL on Unix, which Windows calls the ComSpec. Defaults to 'bash'\nor 'cmd'.\n",
+ "_id": "osenv@0.0.3",
+ "_from": "osenv@latest"
}
diff --git a/node_modules/osenv/test/unix.js b/node_modules/osenv/test/unix.js
index 5d813b040..b72eb0b3f 100644
--- a/node_modules/osenv/test/unix.js
+++ b/node_modules/osenv/test/unix.js
@@ -19,6 +19,9 @@ process.env.TMP = '/tmp'
process.env.TEMP = '/temp'
process.env.PATH = '/opt/local/bin:/usr/local/bin:/usr/bin/:bin'
process.env.PS1 = '(o_o) $ '
+process.env.EDITOR = 'edit'
+process.env.VISUAL = 'visualedit'
+process.env.SHELL = 'zsh'
tap.test('basic unix sanity test', function (t) {
@@ -45,7 +48,6 @@ tap.test('basic unix sanity test', function (t) {
process.env.TEMP = ''
delete require.cache[require.resolve('../osenv.js')]
var osenv = require('../osenv.js')
- console.error('osenv.home', osenv.home())
t.equal(osenv.tmpdir(), '/home/sirUser/tmp')
delete require.cache[require.resolve('../osenv.js')]
@@ -53,5 +55,22 @@ tap.test('basic unix sanity test', function (t) {
osenv.home = function () { return null }
t.equal(osenv.tmpdir(), '/tmp')
+ t.equal(osenv.editor(), 'edit')
+ process.env.EDITOR = ''
+ delete require.cache[require.resolve('../osenv.js')]
+ var osenv = require('../osenv.js')
+ t.equal(osenv.editor(), 'visualedit')
+
+ process.env.VISUAL = ''
+ delete require.cache[require.resolve('../osenv.js')]
+ var osenv = require('../osenv.js')
+ t.equal(osenv.editor(), 'vi')
+
+ t.equal(osenv.shell(), 'zsh')
+ process.env.SHELL = ''
+ delete require.cache[require.resolve('../osenv.js')]
+ var osenv = require('../osenv.js')
+ t.equal(osenv.shell(), 'bash')
+
t.end()
})
diff --git a/node_modules/osenv/test/windows.js b/node_modules/osenv/test/windows.js
index 21852c9e3..dd3fe8070 100644
--- a/node_modules/osenv/test/windows.js
+++ b/node_modules/osenv/test/windows.js
@@ -22,6 +22,9 @@ process.env.TMP = 'C:\\tmp'
process.env.TEMP = 'C:\\temp'
process.env.Path = 'C:\\Program Files\\;C:\\Binary Stuff\\bin'
process.env.PROMPT = '(o_o) $ '
+process.env.EDITOR = 'edit'
+process.env.VISUAL = 'visualedit'
+process.env.ComSpec = 'some-com'
tap.test('basic windows sanity test', function (t) {
var osenv = require('../osenv.js')
@@ -58,5 +61,22 @@ tap.test('basic windows sanity test', function (t) {
osenv.home = function () { return null }
t.equal(osenv.tmpdir(), 'C:\\windows\\temp')
+ t.equal(osenv.editor(), 'edit')
+ process.env.EDITOR = ''
+ delete require.cache[require.resolve('../osenv.js')]
+ var osenv = require('../osenv.js')
+ t.equal(osenv.editor(), 'visualedit')
+
+ process.env.VISUAL = ''
+ delete require.cache[require.resolve('../osenv.js')]
+ var osenv = require('../osenv.js')
+ t.equal(osenv.editor(), 'notepad.exe')
+
+ t.equal(osenv.shell(), 'some-com')
+ process.env.ComSpec = ''
+ delete require.cache[require.resolve('../osenv.js')]
+ var osenv = require('../osenv.js')
+ t.equal(osenv.shell(), 'cmd')
+
t.end()
})