Skip to content

Commit

Permalink
deps: cmd-shim v3 (#315)
Browse files Browse the repository at this point in the history
Work around quoted batch file names

fixed npm/cmd-shim#10
  • Loading branch information
fengmk2 authored Dec 7, 2019
1 parent 903569b commit bbf4ec1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"binary-mirror-config": "^1.19.0",
"bytes": "^3.1.0",
"chalk": "^2.4.2",
"cmd-shim": "^2.0.2",
"cmd-shim": "^3.0.3",
"debug": "^4.1.1",
"destroy": "^1.0.4",
"fs-extra": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion test/bundleDependencies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('test/bundleDependencies.test.js', () => {
});
const bins = await fs.readdir(path.join(tmp, 'node_modules/sqlite3/node_modules/.bin'));
if (process.platform === 'win32') {
assert.deepEqual(bins, [ 'node-pre-gyp', 'node-pre-gyp.cmd' ]);
assert.deepEqual(bins, [ 'node-pre-gyp', 'node-pre-gyp.cmd', 'node-pre-gyp.ps1' ]);
} else {
assert.deepEqual(bins, [ 'node-pre-gyp' ]);
}
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/runscript-with-mocha/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "runscript-with-mocha",
"dependencies": {
"mocha": "3.5.3"
}
}
31 changes: 31 additions & 0 deletions test/runscript-with-mocha.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'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-mocha.test.js', () => {
const root = helper.fixtures('runscript-with-mocha');
const cleanup = helper.cleanup(root);

beforeEach(cleanup);
afterEach(cleanup);

it('should runscript with mocha.cmd', async () => {
await npminstall({
root,
});
const pkg = await readJSON(path.join(root, 'node_modules', 'mocha', 'package.json'));
assert(pkg.name === 'mocha');

let mochaBin = path.join(root, 'node_modules', '.bin', 'mocha');
if (process.platform === 'win32') {
mochaBin = `${mochaBin}.cmd`;
}
const stdio = await runScript(`${mochaBin} -V`, { stdio: 'pipe' });
assert(stdio.stdout.toString().trim() === '3.5.3');
});
});
34 changes: 23 additions & 11 deletions test/uninstallGlobal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,28 @@ describe('test/uninstallGlobal.test.js', () => {
.expect('code', 0)
.end();

await coffee.fork(require.resolve('../bin/uninstall'), [
`--prefix=${tmp}`,
'-g',
'mocha',
])
.debug()
.expect('stdout', /- mocha@\d+\.\d+\.\d+ \.\/test\/fixtures\/tmp\/lib\/node_modules\/mocha/)
.expect('stdout', /- mocha@\d+\.\d+\.\d+ \.\/test\/fixtures\/tmp\/bin\/mocha/)
.expect('stdout', /- mocha@\d+\.\d+\.\d+ \.\/test\/fixtures\/tmp\/bin\/_mocha/)
.expect('code', 0)
.end();
if (process.platform === 'win32') {
await coffee.fork(require.resolve('../bin/uninstall'), [
`--prefix=${tmp}`,
'-g',
'mocha',
])
.debug()
.expect('stdout', /- mocha@\d+\.\d+\.\d+/)
.expect('code', 0)
.end();
} else {
await coffee.fork(require.resolve('../bin/uninstall'), [
`--prefix=${tmp}`,
'-g',
'mocha',
])
.debug()
.expect('stdout', /- mocha@\d+\.\d+\.\d+ \.[\/\\]test[\/\\]fixtures[\/\\]tmp[\/\\]lib[\/\\]node_modules[\/\\]mocha/)
.expect('stdout', /- mocha@\d+\.\d+\.\d+ \.[\/\\]test[\/\\]fixtures[\/\\]tmp[\/\\]bin[\/\\]mocha/)
.expect('stdout', /- mocha@\d+\.\d+\.\d+ \.[\/\\]test[\/\\]fixtures[\/\\]tmp[\/\\]bin[\/\\]_mocha/)
.expect('code', 0)
.end();
}
});
});

0 comments on commit bbf4ec1

Please sign in to comment.