diff options
author | isaacs <i@izs.me> | 2014-04-29 02:00:27 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-04-29 02:00:27 +0400 |
commit | e0048e940d9e5dc97782d733416ee5f9816d520a (patch) | |
tree | 7531250089136fb14abeb61a112a395256fee509 /node_modules/nopt | |
parent | 324a6b2524d5fd3bd96aba7e0f7c133b92ec9a4a (diff) |
nopt@2.2.1
Diffstat (limited to 'node_modules/nopt')
-rw-r--r-- | node_modules/nopt/lib/nopt.js | 5 | ||||
-rw-r--r-- | node_modules/nopt/package.json | 5 | ||||
-rw-r--r-- | node_modules/nopt/test/basic.js | 8 |
3 files changed, 16 insertions, 2 deletions
diff --git a/node_modules/nopt/lib/nopt.js b/node_modules/nopt/lib/nopt.js index 0bacba68f..9efab7af4 100644 --- a/node_modules/nopt/lib/nopt.js +++ b/node_modules/nopt/lib/nopt.js @@ -126,6 +126,11 @@ function validateString (data, k, val) { function validatePath (data, k, val) { if (val === true) return false + val = String(val) + var homePattern = process.platform === 'win32' ? /^~(\/|\\)/ : /^~\// + if (val.match(homePattern) && process.env.HOME) { + val = path.resolve(process.env.HOME, val.substr(2)) + } data[k] = path.resolve(String(val)) return true } diff --git a/node_modules/nopt/package.json b/node_modules/nopt/package.json index 40036f69c..72aba5d36 100644 --- a/node_modules/nopt/package.json +++ b/node_modules/nopt/package.json @@ -1,6 +1,6 @@ { "name": "nopt", - "version": "2.2.0", + "version": "2.2.1", "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", "author": { "name": "Isaac Z. Schlueter", @@ -34,6 +34,7 @@ "url": "https://github.com/isaacs/nopt/issues" }, "homepage": "https://github.com/isaacs/nopt", - "_id": "nopt@2.2.0", + "_id": "nopt@2.2.1", + "_shasum": "2aa09b7d1768487b3b89a9c5aa52335bff0baea7", "_from": "nopt@latest" } diff --git a/node_modules/nopt/test/basic.js b/node_modules/nopt/test/basic.js index 1a6789463..b31dccf54 100644 --- a/node_modules/nopt/test/basic.js +++ b/node_modules/nopt/test/basic.js @@ -15,6 +15,14 @@ test("Empty String results in empty string, not true", function (t) { t.end() }) +test("~ path is resolved to $HOME", function (t) { + var path = require("path") + if (!process.env.HOME) process.env.HOME = "/tmp" + var parsed = nopt({key: path}, {}, ["--key=~/val"], 0) + t.same(parsed.key, path.resolve(process.env.HOME, "val")) + t.end() +}) + test("other tests", function (t) { var util = require("util") |