Skip to content
Permalink
Browse files
fix(add): Always use POSIX paths when computing relative file: specif…
…iers
  • Loading branch information
evocateur committed Jul 31, 2018
1 parent 16d93b6 commit ffe354f145d5e4ab9db1ad608e3fba28c8ab08ad
Showing 2 changed files with 11 additions and 3 deletions.
@@ -147,7 +147,10 @@ class AddCommand extends Command {
if (this.selfSatisfied) {
const node = this.packageGraph.get(name);

return Promise.resolve(this.spec.saveRelativeFileSpec ? node.location : node.version);
// ALWAYS use POSIX path for relative file: specifiers
return Promise.resolve(
this.spec.saveRelativeFileSpec ? path.posix.normalize(node.location) : node.version
);
}

return packageJson(name, { version: fetchSpec }).then(pkg => pkg.version);
@@ -11,8 +11,13 @@ function getRangeToReference(spec, deps, loc, prefix) {
const resolved = spec.type === "tag" ? `${prefix}${spec.version}` : spec.fetchSpec;

if (spec.saveRelativeFileSpec) {
// "version" has been resolved to pkg.location in getPackageVersion()
return npa.resolve(spec.name, path.relative(loc, spec.version), loc).saveSpec;
// ALWAYS render a POSIX file: spec, Windows can deal with it
const where = path.posix.normalize(loc);

// "spec.version" has been resolved to pkg.location in getPackageVersion()
const relativeFileSpec = `file:${path.posix.relative(where, spec.version)}`;

return npa.resolve(spec.name, relativeFileSpec, where).saveSpec;
}

if (prefix && current && semver.intersects(current, resolved)) {

0 comments on commit ffe354f

Please sign in to comment.