Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
allow to override cpu and os on reify
  • Loading branch information
yukukotani committed Sep 8, 2023
commit 06d6a89c26665777d29a36e11d6e25a3edadc5ad
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ module.exports = cls => class Reifier extends cls {
process.emit('time', timer)
this.addTracker('reify', node.name, node.location)

const { npmVersion, nodeVersion } = this.options
const { npmVersion, nodeVersion, cpu, os } = this.options
const p = Promise.resolve().then(async () => {
// when we reify an optional node, check the engine and platform
// first. be sure to ignore the --force and --engine-strict flags,
Expand All @@ -638,7 +638,7 @@ module.exports = cls => class Reifier extends cls {
// eslint-disable-next-line promise/always-return
if (node.optional) {
checkEngine(node.package, npmVersion, nodeVersion, false)
checkPlatform(node.package, false)
checkPlatform(node.package, false, { cpu, os })
}
await this[_checkBins](node)
await this[_extractOrLink](node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3161,6 +3161,44 @@ ArboristNode {
}
`

exports[`test/arborist/reify.js TAP fail to install optional deps with matched os and mismatched cpu with os and cpu options > expect resolving Promise 1`] = `
ArboristNode {
"edgesOut": Map {
"platform-specifying-test-package" => EdgeOut {
"name": "platform-specifying-test-package",
"spec": "1.0.0",
"to": null,
"type": "optional",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-reify-fail-to-install-optional-deps-with-matched-os-and-mismatched-cpu-with-os-and-cpu-options",
"packageName": "platform-test",
"path": "{CWD}/test/arborist/tap-testdir-reify-fail-to-install-optional-deps-with-matched-os-and-mismatched-cpu-with-os-and-cpu-options",
"version": "1.0.0",
}
`

exports[`test/arborist/reify.js TAP fail to install optional deps with mismatched os and matched cpu with os and cpu options > expect resolving Promise 1`] = `
ArboristNode {
"edgesOut": Map {
"platform-specifying-test-package" => EdgeOut {
"name": "platform-specifying-test-package",
"spec": "1.0.0",
"to": null,
"type": "optional",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-reify-fail-to-install-optional-deps-with-mismatched-os-and-matched-cpu-with-os-and-cpu-options",
"packageName": "platform-test",
"path": "{CWD}/test/arborist/tap-testdir-reify-fail-to-install-optional-deps-with-mismatched-os-and-matched-cpu-with-os-and-cpu-options",
"version": "1.0.0",
}
`

exports[`test/arborist/reify.js TAP failing script means install failure, unless ignoreScripts prod-dep-allinstall-fail --ignore-scripts > expect resolving Promise 1`] = `
ArboristNode {
"children": Map {
Expand Down Expand Up @@ -32993,6 +33031,43 @@ exports[`test/arborist/reify.js TAP store files with a custom indenting > must m

`

exports[`test/arborist/reify.js TAP success to install optional deps with matched platform specifications with os and cpu options > expect resolving Promise 1`] = `
ArboristNode {
"children": Map {
"platform-specifying-test-package" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "platform-specifying-test-package",
"spec": "1.0.0",
"type": "optional",
},
},
"location": "node_modules/platform-specifying-test-package",
"name": "platform-specifying-test-package",
"optional": true,
"path": "{CWD}/test/arborist/tap-testdir-reify-success-to-install-optional-deps-with-matched-platform-specifications-with-os-and-cpu-options/node_modules/platform-specifying-test-package",
"resolved": "https://registry.npmjs.org/platform-specifying-test-package/-/platform-specifying-test-package-1.0.0.tgz",
"version": "1.0.0",
},
},
"edgesOut": Map {
"platform-specifying-test-package" => EdgeOut {
"name": "platform-specifying-test-package",
"spec": "1.0.0",
"to": "node_modules/platform-specifying-test-package",
"type": "optional",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-reify-success-to-install-optional-deps-with-matched-platform-specifications-with-os-and-cpu-options",
"packageName": "platform-test",
"path": "{CWD}/test/arborist/tap-testdir-reify-success-to-install-optional-deps-with-matched-platform-specifications-with-os-and-cpu-options",
"version": "1.0.0",
}
`

exports[`test/arborist/reify.js TAP tarball deps with transitive tarball deps > expect resolving Promise 1`] = `
ArboristNode {
"children": Map {
Expand Down
12 changes: 12 additions & 0 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,18 @@ t.test('still do not install optional deps with mismatched platform specificatio
t.test('fail to install deps with mismatched platform specifications', t =>
t.rejects(printReified(fixture(t, 'platform-specification')), { code: 'EBADPLATFORM' }))

t.test('success to install optional deps with matched platform specifications with os and cpu options', t =>
t.resolveMatchSnapshot(printReified(
fixture(t, 'optional-platform-specification'), { os: 'not-your-os', cpu: 'not-your-cpu' })))

t.test('fail to install optional deps with matched os and mismatched cpu with os and cpu options', t =>
t.resolveMatchSnapshot(printReified(
fixture(t, 'optional-platform-specification'), { os: 'not-your-os', cpu: 'another-cpu' })))

t.test('fail to install optional deps with mismatched os and matched cpu with os and cpu options', t =>
t.resolveMatchSnapshot(printReified(
fixture(t, 'optional-platform-specification'), { os: 'another-os', cpu: 'not-your-cpu' })))

t.test('dry run, do not get anything wet', async t => {
const cases = [
'shrinkwrapped-dep-with-lock-empty',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"os": [
"not-your-os"
],
"cpu": [
"not-your-cpu"
],
"_id": "[email protected]",
"_nodeVersion": "12.18.4",
"_npmVersion": "6.14.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
},
"os": [
"not-your-os"
],
"cpu": [
"not-your-cpu"
]
}
},
Expand Down