From e0be08baa5f031d3121a44b4b555f429397d61df Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 7 Dec 2019 22:40:22 +0800 Subject: [PATCH] fix: dont add quotes on node global bin path on Windows (#317) need to wait for https://github.com/npm/cmd-shim/pull/42 to be merged and publish a new version. closes https://github.com/cnpm/npminstall/issues/316 --- lib/bin.js | 2 +- package.json | 2 +- .../runscript-with-egg-doctools/package.json | 6 ++++ test/runscript-with-egg-doctools.test.js | 28 +++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/runscript-with-egg-doctools/package.json create mode 100644 test/runscript-with-egg-doctools.test.js diff --git a/lib/bin.js b/lib/bin.js index 485e1b4a..5d9ca6ab 100644 --- a/lib/bin.js +++ b/lib/bin.js @@ -4,7 +4,7 @@ const chalk = require('chalk'); const debug = require('debug')('npminstall:bin'); const path = require('path'); const fs = require('mz/fs'); -const cmdShim = require('cmd-shim'); +const cmdShim = require('cmd-shim-hotfix'); const utils = require('./utils'); module.exports = bin; diff --git a/package.json b/package.json index 618ee3b7..bcb34a29 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "binary-mirror-config": "^1.19.0", "bytes": "^3.1.0", "chalk": "^2.4.2", - "cmd-shim": "^3.0.3", + "cmd-shim-hotfix": "^3.0.3", "debug": "^4.1.1", "destroy": "^1.0.4", "fs-extra": "^7.0.1", diff --git a/test/fixtures/runscript-with-egg-doctools/package.json b/test/fixtures/runscript-with-egg-doctools/package.json new file mode 100644 index 00000000..bd9ac987 --- /dev/null +++ b/test/fixtures/runscript-with-egg-doctools/package.json @@ -0,0 +1,6 @@ +{ + "name": "runscript-with-egg-doctools", + "dependencies": { + "egg-doctools": "2.9.0" + } +} diff --git a/test/runscript-with-egg-doctools.test.js b/test/runscript-with-egg-doctools.test.js new file mode 100644 index 00000000..fc8207d0 --- /dev/null +++ b/test/runscript-with-egg-doctools.test.js @@ -0,0 +1,28 @@ +'use strict'; + +const assert = require('assert'); +const path = require('path'); +const runScript = require('runscript'); +const readJSON = require('../lib/utils').readJSON; +const npminstall = require('./npminstall'); +const helper = require('./helper'); + +describe('test/runscript-with-egg-doctools.test.js', () => { + const root = helper.fixtures('runscript-with-egg-doctools'); + const cleanup = helper.cleanup(root); + + beforeEach(cleanup); + afterEach(cleanup); + + it('should runscript with egg-doctools bin', async () => { + await npminstall({ + root, + }); + const pkg = await readJSON(path.join(root, 'node_modules', 'egg-doctools', 'package.json')); + assert(pkg.name === 'egg-doctools'); + + const bin = path.join(root, 'node_modules', '.bin', 'doctools'); + const stdio = await runScript(`${bin} -V`, { stdio: 'pipe' }); + assert(stdio.stdout.toString().trim() === '2.9.0'); + }); +});