Skip to content
Closed
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
17 changes: 10 additions & 7 deletions lib/config/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,16 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({

// used to build up the appropriate {add:{...}} options to Arborist.reify
save: npm.config.get('save'),
saveBundle: npm.config.get('save-bundle'),
saveDev: npm.config.get('save-dev'),
saveOptional: npm.config.get('save-optional'),
savePeer: npm.config.get('save-peer'),
saveProd: npm.config.get('save-prod'),
saveExact: npm.config.get('save-exact'),
savePrefix: npm.config.get('save-prefix'),
saveBundle: npm.config.get('save-bundle') && !npm.config.get('save-peer'),
saveType: npm.config.get('save-optional') && npm.config.get('save-peer')
? 'peerOptional'
: npm.config.get('save-optional') ? 'optional'
: npm.config.get('save-dev') ? 'dev'
: npm.config.get('save-peer') ? 'peer'
: npm.config.get('save-prod') ? 'prod'
: null,
savePrefix: npm.config.get('save-exact') ? ''
: npm.config.get('save-prefix'),

// configs for npm-registry-fetch
otp: npm.config.get('otp'),
Expand Down
33 changes: 3 additions & 30 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ function install (where, args, cb) {
where = null
}
// the /path/to/node_modules/..
var globalTop = path.resolve(npm.globalDir, '..')
const globalTop = path.resolve(npm.globalDir, '..')
if (!where) {
where = npm.flatOptions.global
? globalTop
: npm.prefix
}
const {dryRun} = npm.flatOptions.dryRun
const {dryRun} = npm.flatOptions

// TODO: Add warnings for other deprecated flags
if (npm.config.get('dev')) {
Expand All @@ -141,33 +141,6 @@ function install (where, args, cb) {
}
args = args.filter(a => path.resolve(a) !== npm.prefix)

const saveWhere = npm.flatOptions.saveProd ? 'dependencies'
: npm.flatOptions.saveDev ? 'devDependencies'
: npm.flatOptions.saveOptional ? 'optionalDependencies'
: npm.flatOptions.savePeer ? 'peerDependencies'
: 'dependencies'

const {saveBundled} = npm.flatOptions
const add = !args.length ? null : args.reduce((add, a) => {
// npm install foo
// npm install @foo/bar
// npm install foo@bar
// npm install @foo/bar@baz
// npm install git+ssh://foogit.com:bar/baz#boo
const spec = npa(a, where)
add[saveWhere].push(spec)

// XXX need to fix this npm install http://foo.com/bar.tgz --save-bundled
// TODO: arborist should take saveBundled boolean
// Point of research: can you bundle any dep other than production? If not,
// we can pass `bundleDependencies: [array, of, specs]` to arborist,
// it'll do {dependencies:{name:spec, ...}, bundleDependencies:[name,...]}
if (saveBundled && spec.name) {
add.bundleDependencies.push(spec.name)
}
return add
}, { [saveWhere]: [], bundleDependencies: [] })

const arb = new Arborist({
...this.flatOptions,
path: where,
Expand All @@ -181,7 +154,7 @@ function install (where, args, cb) {

const opt = {
...this.flatOptions,
add,
add: args,
}
arb[dryRun ? 'buildIdealTree' : 'reify'](opt).then(tree => {
output('TREEEEEEEE', tree)
Expand Down
24 changes: 15 additions & 9 deletions node_modules/@npmcli/arborist/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 81 additions & 20 deletions node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading