-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support --no-optional on install process (#282)
Don’t install optional dependencies. like yarn does: https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-ignore-optional
- Loading branch information
Showing
12 changed files
with
156 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "ignore-optional", | ||
"dependencies": { | ||
"pinyin": "2.8.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "local-install-pkgs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const coffee = require('coffee'); | ||
const rimraf = require('rimraf'); | ||
const npminstall = path.join(__dirname, '..', 'bin', 'install.js'); | ||
|
||
describe('test/install-ignore-optional.test.js', () => { | ||
let cwd; | ||
function cleanup() { | ||
cwd && rimraf.sync(path.join(cwd, 'node_modules')); | ||
cwd = null; | ||
} | ||
|
||
before(() => cleanup()); | ||
after(() => cleanup()); | ||
|
||
it('should install ignore optionalDependencies', function* () { | ||
cwd = path.join(__dirname, 'fixtures', 'ignore-optional'); | ||
yield coffee.fork(npminstall, [ '--no-optional', '--production', '-d' ], { cwd }) | ||
.debug() | ||
.notExpect('stderr', /optional install error/) | ||
.notExpect('stderr', /node-gyp rebuild/) | ||
.expect('stdout', /pinyin@2.8.3 installed/) | ||
.expect('code', 0) | ||
.end(); | ||
assert(!fs.existsSync(path.join(cwd, 'node_modules/pinyin/node_modules/nodejieba'))); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const rimraf = require('rimraf'); | ||
const path = require('path'); | ||
const coffee = require('coffee'); | ||
const npminstall = path.join(__dirname, '..', 'bin', 'install.js'); | ||
|
||
describe('test/local-install-pkgs.test.js', () => { | ||
const root = path.join(__dirname, 'fixtures', 'local-install-pkgs'); | ||
|
||
function cleanup() { | ||
rimraf.sync(path.join(root, 'node_modules')); | ||
} | ||
|
||
beforeEach(cleanup); | ||
afterEach(cleanup); | ||
|
||
it('should install pkg and dont link latestVersions', function* () { | ||
yield coffee.fork(npminstall, [ 'koa' ], { cwd: root }) | ||
.debug() | ||
.expect('code', 0) | ||
.notExpect('stdout', /Linked \d+ latest versions/) | ||
.end(); | ||
const names = fs.readdirSync(path.join(root, 'node_modules')) | ||
.filter(n => !/^[\.\_]/.test(n)); | ||
assert(names.length === 1); | ||
assert(names[0] === 'koa'); | ||
}); | ||
}); |