From 0bbd303857e88ff7eca3fc24fe01069344707ecf Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 25 Dec 2019 18:58:22 -0800 Subject: [PATCH] fix: resolve folder that is passed in Root cause of https://github.com/npm/cli/issues/613 --- index.js | 1 + test/link-bins.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4f6d3c0..79c2cb5 100644 --- a/index.js +++ b/index.js @@ -18,6 +18,7 @@ module.exports = BB.promisify(binLinks) function binLinks (pkg, folder, global, opts, cb) { pkg = normalize(pkg) + folder = path.resolve(folder) // if it's global, and folder is in {prefix}/node_modules, // then bins are in {prefix}/bin diff --git a/test/link-bins.js b/test/link-bins.js index ce2719a..3e5a7de 100644 --- a/test/link-bins.js +++ b/test/link-bins.js @@ -77,7 +77,10 @@ t.test('foo package cannot link, pre-existing stuff there', t => { }) t.test('foo package can link with --force link', t => { - const foo = resolve(me, 'node_modules/foo') + const cwd = process.cwd() + t.teardown(() => process.chdir(cwd)) + process.chdir(me) + const foo = 'node_modules/foo' mkdirp(foo) const pkg = { name: 'foo',