realize-package-specifier
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -8,3 +8,3 @@ "use strict" | ||
module.exports = function (spec, where, cb) { | ||
if (where instanceof Function) cb = where, where = null | ||
if (where instanceof Function) { cb = where; where = null } | ||
if (where == null) where = "." | ||
@@ -18,3 +18,5 @@ cb = dz(cb) | ||
} | ||
var specpath = path.resolve(where, dep.type == "local" ? dep.spec : spec) | ||
var specpath = dep.type == "local" | ||
? path.resolve(where, dep.spec) | ||
: path.resolve(spec) | ||
fs.stat(specpath, function (er, s) { | ||
@@ -21,0 +23,0 @@ if (er) return finalize() |
{ | ||
"name": "realize-package-specifier", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Like npm-package-arg, but more so, producing full file paths and differentiating local tar and directory sources.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,3 +12,6 @@ "use strict" | ||
nopackagejson: /[\/\\]c[\/\\]package.json$/, | ||
remotename: /[\/\\]d$/ | ||
remotename: /[\/\\]d$/, | ||
packagedirlikegithub: /[\/\\]e[\/\\]1$/, | ||
packagejsonlikegithub: /[\/\\]e[\/\\]1[\/\\]package.json$/, | ||
github: /[\/\\]e[\/\\]2$/ | ||
} | ||
@@ -37,2 +40,11 @@ | ||
} | ||
else if (re.packagedirlikegithub.test(path)) { | ||
callback(null,{isDirectory:function(){ return true }}) | ||
} | ||
else if (re.packagejsonlikegithub.test(path)) { | ||
callback(null,{}) | ||
} | ||
else if (re.github.test(path)) { | ||
callback(new Error("EFILENOTFOUND")) | ||
} | ||
else { | ||
@@ -46,3 +58,3 @@ throw new Error("Unknown stat fixture path: "+path) | ||
test("realize-package-specifier", function (t) { | ||
t.plan(8) | ||
t.plan(10) | ||
rps("a.tar.gz", function (err, result) { | ||
@@ -72,2 +84,8 @@ t.is(result.type, "local", "local tarball") | ||
}) | ||
rps("e/1", function (err, result) { | ||
t.is(result.type, "directory", "local package directory") | ||
}) | ||
rps("e/2", function (err, result) { | ||
t.is(result.type, "github", "github package dependency") | ||
}) | ||
}) |
@@ -1,3 +0,3 @@ | ||
var test = require('tap').test; | ||
var rps = require('../index.js') | ||
var test = require("tap").test; | ||
var rps = require("../index.js") | ||
var path = require("path") | ||
@@ -106,3 +106,3 @@ | ||
type: "local", | ||
spec: "path/to/foo", | ||
spec: path.resolve(__dirname,"..","path/to/foo"), | ||
raw: "file:path/to/foo" | ||
@@ -114,3 +114,3 @@ }, | ||
type: "local", | ||
spec: "~/path/to/foo", | ||
spec: path.resolve(__dirname,"..","~/path/to/foo"), | ||
raw: "file:~/path/to/foo" | ||
@@ -122,3 +122,3 @@ }, | ||
type: "local", | ||
spec: "../path/to/foo", | ||
spec: path.resolve(__dirname,"..","../path/to/foo"), | ||
raw: "file:../path/to/foo" | ||
@@ -194,3 +194,3 @@ }, | ||
Object.keys(tests).forEach(function (arg) { | ||
rps(arg, function(err, res) { | ||
rps(arg, path.resolve(__dirname,'..'), function(err, res) { | ||
t.notOk(err, "No error") | ||
@@ -203,7 +203,7 @@ t.type(res, "Result") | ||
// Completely unreasonable invalid garbage throws an error | ||
rps("this is not a \0 valid package name or url", function (err) { | ||
rps("this is not a \0 valid package name or url", path.resolve(__dirname,'..'), function (err) { | ||
t.ok(err, "error") | ||
}) | ||
rps("gopher://yea right", function (err) { | ||
rps("gopher://yea right", path.resolve(__dirname,'..'), function (err) { | ||
t.ok(err, "Unsupported URL Type: gopher://yea right") | ||
@@ -210,0 +210,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12131
331