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

fix: dont add quotes on node global bin path on Windows #318

Merged
merged 3 commits into from
Dec 10, 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 lib/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Member

Choose a reason for hiding this comment

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

这个改了啥?后面修复会合并到原来的模块么?

Copy link
Member

Choose a reason for hiding this comment

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

看到了。。

const utils = require('./utils');

module.exports = bin;
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"npmupdate": "bin/update.js"
},
"scripts": {
"test": "mocha -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js",
"test-cov": "istanbul cover --report none --print none node_modules/mocha/bin/_mocha -- -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js && istanbul report text-summary json lcov",
"test-local": "npm_china=true local=true mocha -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js",
"test": "mocha -r thunk-mocha -t 200000 test/*.test.js",
"test-cov": "istanbul cover --report none --print none node_modules/mocha/bin/_mocha -- -r thunk-mocha -t 200000 test/*.test.js && istanbul report text-summary json lcov",
"test-local": "npm_china=true local=true mocha -r thunk-mocha -t 200000 test/*.test.js",
"lint": "eslint . --fix",
"ci": "npm run lint && npm run test-cov",
"autod": "autod"
Expand All @@ -28,7 +28,7 @@
"binary-mirror-config": "^1.19.0",
"bytes": "^2.5.0",
"chalk": "^1.1.3",
"cmd-shim": "^2.0.2",
"cmd-shim-hotfix": "^3.0.3",
"co": "^4.6.0",
"co-fs-extra": "^1.2.1",
"co-parallel": "^1.0.0",
Expand Down Expand Up @@ -61,11 +61,9 @@
"eslint": "3",
"eslint-config-egg": "3",
"http-proxy": "^1.16.2",
"intelli-espower-loader": "1",
"istanbul": "*",
"mm": "^2.2.1",
"mocha": "3",
"power-assert": "1",
"thunk-mocha": "1"
},
"homepage": "https://github.com/cnpm/npminstall",
Expand Down
2 changes: 1 addition & 1 deletion test/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const semver = require('semver');
const spawn = require('child_process').spawn;
const npminstall = require('./npminstall');

if (semver.satisfies(process.version, '< 6.0.0')) {
if (semver.satisfies(process.version, '< 8.0.0')) {
process.exit(0);
}

Expand Down
51 changes: 27 additions & 24 deletions test/bigPackage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@

const path = require('path');
const rimraf = require('rimraf');
const semver = require('semver');
const npminstall = require('./npminstall');

describe('test/bigPackage.test.js', () => {
function testcase(name) {
describe(name, () => {
const root = path.join(__dirname, 'fixtures', name);
if (semver.satisfies(process.version, '>= 6.0.0')) {
describe('test/bigPackage.test.js', () => {
function testcase(name) {
describe(name, () => {
const root = path.join(__dirname, 'fixtures', name);

function cleanup() {
rimraf.sync(path.join(root, 'node_modules'));
}
function cleanup() {
rimraf.sync(path.join(root, 'node_modules'));
}

beforeEach(cleanup);
afterEach(cleanup);
beforeEach(cleanup);
afterEach(cleanup);

it('should install success', function* () {
yield npminstall({
root,
trace: true,
it('should install success', function* () {
yield npminstall({
root,
trace: true,
});
});
});
});
}
}

if (process.platform !== 'win32') {
[
'spmtest',
'spmwebpacktest',
].forEach(testcase);
}

if (process.platform !== 'win32') {
[
'spmtest',
'spmwebpacktest',
'standardtest',
].forEach(testcase);
}

[
'standardtest',
].forEach(testcase);
});
});
}
2 changes: 1 addition & 1 deletion test/bundleDependencies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('test/bundleDependencies.test.js', () => {
});
const bins = yield 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
53 changes: 28 additions & 25 deletions test/concurrency-install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,37 @@

const path = require('path');
const rimraf = require('rimraf');
const semver = require('semver');
const npminstall = require('./npminstall');

describe('test/concurrency-install.test.js', () => {
const root1 = path.join(__dirname, 'fixtures', 'concurrency1');
const root2 = path.join(__dirname, 'fixtures', 'concurrency2');
const cacheDir = path.join(__dirname, 'fixtures', '.tmp');
if (semver.satisfies(process.version, '>= 6.0.0')) {
describe('test/concurrency-install.test.js', () => {
const root1 = path.join(__dirname, 'fixtures', 'concurrency1');
const root2 = path.join(__dirname, 'fixtures', 'concurrency2');
const cacheDir = path.join(__dirname, 'fixtures', '.tmp');

function cleanup() {
rimraf.sync(cacheDir);
rimraf.sync(path.join(root1, 'node_modules'));
rimraf.sync(path.join(root2, 'node_modules'));
}
function cleanup() {
rimraf.sync(cacheDir);
rimraf.sync(path.join(root1, 'node_modules'));
rimraf.sync(path.join(root2, 'node_modules'));
}

beforeEach(cleanup);
afterEach(cleanup);
beforeEach(cleanup);
afterEach(cleanup);

it('should concurrency install success', function* () {
yield [
npminstall({
root: root1,
cacheDir,
detail: true,
}),
npminstall({
root: root2,
cacheDir,
detail: true,
}),
];
it('should concurrency install success', function* () {
yield [
npminstall({
root: root1,
cacheDir,
detail: true,
}),
npminstall({
root: root2,
cacheDir,
detail: true,
}),
];
});
});
});
}
4 changes: 3 additions & 1 deletion test/installScopeRegistry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const helper = require('./helper');
const npminstall = require('./npminstall');

describe('test/installScopeRegistry.test.js', () => {
const [ tmp, cleanup ] = helper.tmp();
const items = helper.tmp();
const tmp = items[0];
const cleanup = items[1];
let mockCnpmrc;

before(() => {
Expand Down
71 changes: 37 additions & 34 deletions test/proxy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,48 @@ const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const mm = require('mm');
const coffee = require('coffee');
const proxy = require('./fixtures/reverse-proxy');
const semver = require('semver');

const npminstallBin = path.join(__dirname, '../bin/install.js');
if (semver.satisfies(process.version, '>= 6.0.0')) {
const proxy = require('./fixtures/reverse-proxy');
const npminstallBin = path.join(__dirname, '../bin/install.js');

describe('test/proxy.test.js', () => {
let port;
let proxyUrl;
before(done => {
proxy.listen(0, () => {
port = proxy.address().port;
proxyUrl = 'http://127.0.0.1:' + port;
console.log('proxy: %s', proxyUrl);
done();
describe('test/proxy.test.js', () => {
let port;
let proxyUrl;
before(done => {
proxy.listen(0, () => {
port = proxy.address().port;
proxyUrl = 'http://127.0.0.1:' + port;
console.log('proxy: %s', proxyUrl);
done();
});
});
});
after(() => proxy.close());
after(() => proxy.close());

const tmp = path.join(__dirname, 'fixtures', 'tmp');
const tmp = path.join(__dirname, 'fixtures', 'tmp');

function cleanup() {
rimraf.sync(tmp);
}
function cleanup() {
rimraf.sync(tmp);
}

beforeEach(() => {
cleanup();
mkdirp.sync(tmp);
});
afterEach(cleanup);
afterEach(mm.restore);
beforeEach(() => {
cleanup();
mkdirp.sync(tmp);
});
afterEach(cleanup);
afterEach(mm.restore);

it('should install from proxy', () => {
return coffee.fork(npminstallBin, [
'--proxy', proxyUrl,
'koa', 'pedding',
], {
cwd: tmp,
})
.debug()
.expect('code', 0)
.end();
it('should install from proxy', () => {
return coffee.fork(npminstallBin, [
'--proxy', proxyUrl,
'koa', 'pedding',
], {
cwd: tmp,
})
.debug()
.expect('code', 0)
.end();
});
});
});
}
4 changes: 1 addition & 3 deletions test/uninstallGlobal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ describe('test/uninstallGlobal.test.js', () => {
'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('stdout', /- mocha@\d+\.\d+\.\d+/)
.expect('code', 0)
.end(done);
});
Expand Down