Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: cmd-shim v3 #315

Merged
merged 5 commits into from
Dec 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

解决 windows cmd 在 appveyor 跑失败的问题

"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') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确保在 appveyor 下跑成功

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();
}
});
});