Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -7784,4 +7784,4 @@ ArboristNode {
"name": "yarn-lock-mkdirp-file-dep",
"path": "yarn-lock-mkdirp-file-dep",
}
`
`
Original file line number Diff line number Diff line change
Expand Up @@ -124,82 +124,6 @@ ArboristNode {
}
`

exports[`test/arborist/pruner.js TAP prune with lockfile with implicit optional peer dependencies > should remove all deps from reified tree 1`] = `
ArboristNode {
"children": Map {
"dedent" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "dedent",
"spec": "^1.6.0",
"type": "prod",
},
},
"edgesOut": Map {
"babel-plugin-macros" => EdgeOut {
"name": "babel-plugin-macros",
"spec": "^3.1.0",
"to": null,
"type": "peerOptional",
},
},
"location": "node_modules/dedent",
"name": "dedent",
"path": "{CWD}/test/arborist/tap-testdir-pruner-prune-with-lockfile-with-implicit-optional-peer-dependencies/node_modules/dedent",
"resolved": "https://registry.npmjs.org/dedent/-/dedent-1.6.0.tgz",
"version": "1.6.0",
},
},
"edgesOut": Map {
"dedent" => EdgeOut {
"name": "dedent",
"spec": "^1.6.0",
"to": "node_modules/dedent",
"type": "prod",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-pruner-prune-with-lockfile-with-implicit-optional-peer-dependencies",
"packageName": "prune-lockfile-optional-peer",
"path": "{CWD}/test/arborist/tap-testdir-pruner-prune-with-lockfile-with-implicit-optional-peer-dependencies",
"version": "1.0.0",
}
`

exports[`test/arborist/pruner.js TAP prune with lockfile with implicit optional peer dependencies > should remove optional peer dependencies in package-lock.json 1`] = `
Object {
"lockfileVersion": 3,
"name": "prune-lockfile-optional-peer",
"packages": Object {
"": Object {
"dependencies": Object {
"dedent": "^1.6.0",
},
"name": "prune-lockfile-optional-peer",
"version": "1.0.0",
},
"node_modules/dedent": Object {
"integrity": "sha512-F1Z+5UCFpmQUzJa11agbyPVMbpgT/qA3/SKyJ1jyBgm7dUcUEa8v9JwDkerSQXfakBwFljIxhOJqGkjUwZ9FSA==",
"license": "MIT",
"peerDependencies": Object {
"babel-plugin-macros": "^3.1.0",
},
"peerDependenciesMeta": Object {
"babel-plugin-macros": Object {
"optional": true,
},
},
"resolved": "https://registry.npmjs.org/dedent/-/dedent-1.6.0.tgz",
"version": "1.6.0",
},
},
"requires": true,
"version": "1.0.0",
}
`

exports[`test/arborist/pruner.js TAP prune workspaces > must match snapshot 1`] = `
ArboristNode {
"children": Map {
Expand Down
27 changes: 7 additions & 20 deletions workspaces/arborist/test/arborist/pruner.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,19 @@ t.test('prune with lockfile', async t => {
})

t.test('prune with lockfile with implicit optional peer dependencies', async t => {
registry.audit({})
const opts = {}

// todo: for some reason on Windows when doing this test NPM looks for
// the cache in the home directory, resulting in an unexpected real
// call being made to the registry
if (process.platform === 'win32') {
opts.cache = 'C:\\npm\\cache\\_cacache'
}

const path = fixture(t, 'prune-lockfile-optional-peer')
const tree = await pruneTree(path, opts)
const tree = await pruneTree(path, { audit: false })

const dep = tree.children.get('dedent')
t.ok(dep, 'required prod dep was pruned from tree')
t.ok(dep, 'required prod dep was not pruned from tree')

const optionalPeerDep = tree.children.get('babel-plugin-macros')
t.notOk(optionalPeerDep, 'all listed optional peer deps pruned from tree')
t.notOk(optionalPeerDep, 'optional peer dep was pruned from tree')

t.matchSnapshot(
require(path + '/package-lock.json'),
'should remove optional peer dependencies in package-lock.json'
)
t.matchSnapshot(
printTree(tree),
'should remove all deps from reified tree'
t.notMatch(
fs.readFileSync(path + '/package-lock.json'),
'node_modules/babel-plugin-macros',
'should remove optional peer dep from package-lock.json'
)
})

Expand Down
16 changes: 4 additions & 12 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2444,28 +2444,20 @@ t.test('move aside symlink clutter', async t => {
file: 'do not delete me please',
'package.json': JSON.stringify({ name: 'ABBREV', version: '1.0.0' }),
},
'sensitivity-test': t.fixture('symlink', './target'),
node_modules: {
ABBREV: t.fixture('symlink', '../target'),
},
})

// check to see if we're on a case-insensitive fs
try {
const st = fs.lstatSync(path + '/SENSITIVITY-TEST')
const st = fs.lstatSync(path + '/node_modules/abbrev')
t.equal(st.isSymbolicLink(), true, 'fs is case insensitive')
} catch (er) {
t.plan(0, 'case sensitive file system, test not relevant')
return
}

const kReifyPackages = Symbol.for('reifyPackages')
const reifyPackages = Arborist.prototype[kReifyPackages]
t.teardown(() => Arborist.prototype[kReifyPackages] = reifyPackages)
Arborist.prototype[kReifyPackages] = async function () {
fs.mkdirSync(path + '/node_modules')
fs.symlinkSync('../target', path + '/node_modules/ABBREV')
Arborist.prototype[kReifyPackages] = reifyPackages
return this[kReifyPackages]()
}

createRegistry(t, true)
const tree = await printReified(path)
const st = fs.lstatSync(path + '/node_modules/abbrev')
Expand Down
2 changes: 1 addition & 1 deletion workspaces/arborist/test/fixtures/create-reify-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ if (hiddenLocks.length) {
}
}

writeFileSync(outFile, `// generated from ${rel}
writeFileSync(outFile, `// generated from ${rel.replaceAll('\\', '/')}
module.exports = t => {
const path = ${output}
return path
Expand Down

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

Loading
Loading