Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2022-11-09 23:50:30 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-11-10 00:14:09 +0300
commit139bce18ab1e6f0417bbfdf35a1ab2326838c604 (patch)
tree7b66d681ab7e6d93326a1a513688577a3a9103d6
parentfd856d3d2ee91d147ca48e2769b0aa8ab52a61c1 (diff)
chore: fix async realpath in smoke publish (#5836)
-rw-r--r--smoke-tests/tap-snapshots/test/index.js.test.cjs10
-rw-r--r--smoke-tests/test/fixtures/setup.js38
2 files changed, 34 insertions, 14 deletions
diff --git a/smoke-tests/tap-snapshots/test/index.js.test.cjs b/smoke-tests/tap-snapshots/test/index.js.test.cjs
index 4c02dc044..de8774852 100644
--- a/smoke-tests/tap-snapshots/test/index.js.test.cjs
+++ b/smoke-tests/tap-snapshots/test/index.js.test.cjs
@@ -32,13 +32,13 @@ All commands:
unstar, update, version, view, whoami
Specify configs in the ini-formatted file:
- {CWD}/{TESTDIR}/project/.npmrc
+ {NPM}/{TESTDIR}/project/.npmrc
or on the command line via: npm <command> --key=value
More configuration info: npm help config
Configuration fields: npm help 7 config
-npm {CWD}
+npm {NPM}
`
exports[`test/index.js TAP basic npm ci > should throw mismatch deps in lock file error 1`] = `
@@ -107,7 +107,7 @@ project@1.0.0
`
exports[`test/index.js TAP basic npm init > should have successful npm init result 1`] = `
-Wrote to {CWD}/{TESTDIR}/project/package.json:
+Wrote to {NPM}/{TESTDIR}/project/package.json:
{
"name": "project",
@@ -231,7 +231,7 @@ Object {
`
exports[`test/index.js TAP basic npm ls > should have expected ls output 1`] = `
-project@1.0.0 {CWD}/{TESTDIR}/project
+project@1.0.0 {NPM}/{TESTDIR}/project
+-- abbrev@1.0.4
\`-- promise-all-reject-late@5.0.0
`
@@ -347,7 +347,7 @@ exports[`test/index.js TAP basic npm pkg set scripts > should have expected set-
`
exports[`test/index.js TAP basic npm prefix > should have expected prefix output 1`] = `
-{CWD}/{TESTDIR}/project
+{NPM}/{TESTDIR}/project
`
exports[`test/index.js TAP basic npm run-script > should have expected run-script output 1`] = `
diff --git a/smoke-tests/test/fixtures/setup.js b/smoke-tests/test/fixtures/setup.js
index 596ec4872..4291006b4 100644
--- a/smoke-tests/test/fixtures/setup.js
+++ b/smoke-tests/test/fixtures/setup.js
@@ -32,19 +32,32 @@ const testdirHelper = (obj) => {
}
const getSpawnArgs = async () => {
- const cliBin = join('bin', 'npm-cli.js')
+ const cliBin = join('bin', 'npm')
+ const cliJsBin = join('bin', 'npm-cli.js')
+ const npmLinks = await which('npm', { all: true })
+ const npmPaths = await Promise.all(npmLinks.map(npm => fs.realpath(npm)))
+
+ const cleanNpmPaths = [...new Set([
+ CLI_ROOT,
+ join(CLI_ROOT, cliBin),
+ join(CLI_ROOT, cliJsBin),
+ ...npmLinks,
+ ...npmPaths,
+ ...npmPaths.map(n => n.replace(sep + cliBin, '')),
+ ...npmPaths.map(n => n.replace(sep + cliJsBin, '')),
+ ])]
if (SMOKE_PUBLISH_NPM) {
return {
command: ['npm'],
- NPM: await which('npm').then(p => fs.realpath(p).replace(sep + cliBin)),
+ NPM: cleanNpmPaths,
}
}
return {
- command: [process.execPath, join(CLI_ROOT, cliBin)],
+ command: [process.execPath, join(CLI_ROOT, cliJsBin)],
NODE: process.execPath,
- NPM: join(CLI_ROOT, cliBin),
+ NPM: cleanNpmPaths,
}
}
@@ -87,17 +100,24 @@ module.exports = async (t, { testdir = {}, debug } = {}) => {
t.strictSame(registry.nock.activeMocks(), [], 'no active mocks after each')
})
- const { command, ...spawnPaths } = await getSpawnArgs()
- const cleanPaths = Object.entries({ ...spawnPaths, CWD: CLI_ROOT })
+ const debugLog = debug || CI ? (...a) => console.error(...a) : () => {}
+ const { command, ...spawnPaths } = await getSpawnArgs({ log: debugLog })
+ const cleanPaths = Object.entries(spawnPaths)
const cleanOutput = s => {
// sometimes we print normalized paths in snapshots regardless of
// platform so replace those first then replace platform style paths
for (const [key, value] of cleanPaths) {
- s = s.split(normalizePath(value)).join(`{${key}}`)
+ const values = [].concat(value)
+ for (const v of values) {
+ s = s.split(normalizePath(v)).join(`{${key}}`)
+ }
}
for (const [key, value] of cleanPaths) {
- s = s.split(value).join(`{${key}}`)
+ const values = [].concat(value)
+ for (const v of values) {
+ s = s.split(v).join(`{${key}}`)
+ }
}
return s
.split(relative(CLI_ROOT, t.testdirName)).join('{TESTDIR}')
@@ -110,7 +130,7 @@ module.exports = async (t, { testdir = {}, debug } = {}) => {
.replace(/^.*debug-[0-9]+.log$/gm, '')
.replace(/in \d+ms$/gm, 'in {TIME}')
}
- const log = debug || CI ? (...a) => console.error(cleanOutput(a.join(' '))) : () => {}
+ const log = (...a) => debugLog(cleanOutput(a.join(' ')))
t.cleanSnapshot = cleanOutput
const npm = async (...args) => {