Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support tests on win32 #408

Merged
merged 9 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 5 additions & 1 deletion lib/util/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ module.exports = (npmBin, npmCommand, cwd, env, extra) => {
const isJS = npmBin.endsWith('.js')
const cmd = isJS ? process.execPath : npmBin
const args = (isJS ? [npmBin] : []).concat(npmCommand)

// Avoid "spawn npm ENOENT" on Windows by setting { shell: true }
const shell = (process.platform === 'win32' && npmBin === 'npm') ? true : undefined
mbtools marked this conversation as resolved.
Show resolved Hide resolved

// when installing to run the `prepare` script for a git dep, we need
// to ensure that we don't run into a cycle of checking out packages
// in temp directories. this lets us link previously-seen repos that
// are also being prepared.

return spawn(cmd, args, { cwd, env }, extra)
return spawn(cmd, args, { cwd, env, shell }, extra)
}
40 changes: 20 additions & 20 deletions tap-snapshots/test/dir.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`test/dir.js TAP basic > extract 1`] = `
Object {
"from": "file:test/fixtures/abbrev",
"integrity": "{integrity}",
"resolved": "\${CWD}/test/fixtures/abbrev",
"resolved": "{CWD}/test/fixtures/abbrev",
}
`

Expand All @@ -18,7 +18,7 @@ Object {
"_from": "file:test/fixtures/abbrev",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/abbrev",
"_resolved": "{CWD}/test/fixtures/abbrev",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
Expand Down Expand Up @@ -76,15 +76,15 @@ Object {
"_from": "file:test/fixtures/abbrev",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/abbrev",
"_resolved": "{CWD}/test/fixtures/abbrev",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
"tap": "^10.1",
},
"dist": Object {
"integrity": null,
"tarball": "file:\${CWD}/test/fixtures/abbrev",
"tarball": "file:{CWD}/test/fixtures/abbrev",
},
"files": Array [
"abbrev.js",
Expand All @@ -110,7 +110,7 @@ Object {
"_from": "file:test/fixtures/abbrev",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/abbrev",
"_resolved": "{CWD}/test/fixtures/abbrev",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
Expand Down Expand Up @@ -144,15 +144,15 @@ Object {
"_from": "file:test/fixtures/abbrev",
"_id": "[email protected]",
"_integrity": "sha512-whatever-this-is-only-checked-if-we-extract-it",
"_resolved": "\${CWD}/test/fixtures/abbrev",
"_resolved": "{CWD}/test/fixtures/abbrev",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
"tap": "^10.1",
},
"dist": Object {
"integrity": "{integrity}",
"tarball": "file:\${CWD}/test/fixtures/abbrev",
"tarball": "file:{CWD}/test/fixtures/abbrev",
},
"files": Array [
"abbrev.js",
Expand All @@ -177,15 +177,15 @@ exports[`test/dir.js TAP make bins executable > results of unpack 1`] = `
Object {
"from": "file:test/fixtures/bin-object",
"integrity": "{integrity}",
"resolved": "\${CWD}/test/fixtures/bin-object",
"resolved": "{CWD}/test/fixtures/bin-object",
}
`

exports[`test/dir.js TAP responds to foregroundScripts: true > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "{integrity}",
"resolved": "\${CWD}/test/fixtures/prepare-script",
"resolved": "{CWD}/test/fixtures/prepare-script",
}
`

Expand All @@ -202,7 +202,7 @@ Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"_resolved": "{CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
Expand All @@ -227,13 +227,13 @@ Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"_resolved": "{CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
"dist": Object {
"integrity": null,
"tarball": "file:\${CWD}/test/fixtures/prepare-script",
"tarball": "file:{CWD}/test/fixtures/prepare-script",
},
"license": "ISC",
"main": "index.js",
Expand All @@ -251,7 +251,7 @@ exports[`test/dir.js TAP with prepare script > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "{integrity}",
"resolved": "\${CWD}/test/fixtures/prepare-script",
"resolved": "{CWD}/test/fixtures/prepare-script",
}
`

Expand All @@ -268,7 +268,7 @@ Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"_resolved": "{CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
Expand All @@ -293,13 +293,13 @@ Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"_resolved": "{CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
"dist": Object {
"integrity": null,
"tarball": "file:\${CWD}/test/fixtures/prepare-script",
"tarball": "file:{CWD}/test/fixtures/prepare-script",
},
"license": "ISC",
"main": "index.js",
Expand All @@ -317,7 +317,7 @@ exports[`test/dir.js TAP with prepare script with scriptshell configuration > ex
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "{integrity}",
"resolved": "\${CWD}/test/fixtures/prepare-script",
"resolved": "{CWD}/test/fixtures/prepare-script",
}
`

Expand All @@ -334,7 +334,7 @@ Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"_resolved": "{CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
Expand All @@ -359,13 +359,13 @@ Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"_resolved": "{CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
"dist": Object {
"integrity": null,
"tarball": "file:\${CWD}/test/fixtures/prepare-script",
"tarball": "file:{CWD}/test/fixtures/prepare-script",
},
"license": "ISC",
"main": "index.js",
Expand Down
22 changes: 11 additions & 11 deletions tap-snapshots/test/file.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`test/file.js TAP basic > extract 1`] = `
Object {
"from": "file:test/fixtures/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
}
`

Expand All @@ -18,7 +18,7 @@ Object {
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
"_id": "[email protected]",
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"_resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
Expand Down Expand Up @@ -76,15 +76,15 @@ Object {
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
"_id": "[email protected]",
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"_resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
"tap": "^10.1",
},
"dist": Object {
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"tarball": "file:\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"tarball": "file:{CWD}/test/fixtures/abbrev-1.1.1.tgz",
},
"files": Array [
"abbrev.js",
Expand All @@ -109,31 +109,31 @@ exports[`test/file.js TAP make bins executable bin-good > results of unpack 1`]
Object {
"from": "file:test/fixtures/bin-good.tgz",
"integrity": "sha512-Fx11OiHxV82CztnPk+k0S6H/66J4/eUzZEMGX2dJjP+Mxfrm8fSzE4SQG604zWk17ELZsOGENCdWSkvj4cpjUw==",
"resolved": "\${CWD}/test/fixtures/bin-good.tgz",
"resolved": "{CWD}/test/fixtures/bin-good.tgz",
}
`

exports[`test/file.js TAP make bins executable bin-object > results of unpack 1`] = `
Object {
"from": "file:test/fixtures/bin-object.tgz",
"integrity": "sha512-TqzCjecWyQe8vqLbT0nv/OaWf0ptRZ2DnPmiuGUYJJb70shp02+/uu37IJSkM2ZEP1SAOeKrYrWPVIIYW+d//g==",
"resolved": "\${CWD}/test/fixtures/bin-object.tgz",
"resolved": "{CWD}/test/fixtures/bin-object.tgz",
}
`

exports[`test/file.js TAP make bins executable bin-string > results of unpack 1`] = `
Object {
"from": "file:test/fixtures/bin-string.tgz",
"integrity": "sha512-iCc87DMYVMofO221ksAlMD88Zgsr4OIvqeX73KxTPikWaQPvBFZpzI9FGWnD4PTLTyJzOSETQh86+IwEidJRZg==",
"resolved": "\${CWD}/test/fixtures/bin-string.tgz",
"resolved": "{CWD}/test/fixtures/bin-string.tgz",
}
`

exports[`test/file.js TAP with readme > extract-slow-json 1`] = `
Object {
"from": "file:test/fixtures/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
}
`

Expand All @@ -142,7 +142,7 @@ Object {
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
"_id": "[email protected]",
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"_resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
"author": Object {
"email": "[email protected]",
"name": "Isaac Z. Schlueter",
Expand Down Expand Up @@ -237,7 +237,7 @@ Object {
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
"_id": "[email protected]",
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"_resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
"author": Object {
"email": "[email protected]",
"name": "Isaac Z. Schlueter",
Expand All @@ -251,7 +251,7 @@ Object {
},
"dist": Object {
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"tarball": "file:\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"tarball": "file:{CWD}/test/fixtures/abbrev-1.1.1.tgz",
},
"files": Array [
"abbrev.js",
Expand Down
14 changes: 7 additions & 7 deletions tap-snapshots/test/index.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`test/index.js TAP > extract 1`] = `
Object {
"from": "file:test/fixtures/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
}
`

Expand All @@ -18,7 +18,7 @@ Object {
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
"_id": "[email protected]",
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"_resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
Expand Down Expand Up @@ -46,7 +46,7 @@ Object {
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
"_id": "[email protected]",
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"_resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
Expand Down Expand Up @@ -80,15 +80,15 @@ Object {
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
"_id": "[email protected]",
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"_resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
"author": "Isaac Z. Schlueter <[email protected]>",
"description": "Like ruby's abbrev module, but in js",
"devDependencies": Object {
"tap": "^10.1",
},
"dist": Object {
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"tarball": "file:\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"tarball": "file:{CWD}/test/fixtures/abbrev-1.1.1.tgz",
},
"files": Array [
"abbrev.js",
Expand All @@ -110,13 +110,13 @@ Object {
`

exports[`test/index.js TAP > resolve 1`] = `
\${CWD}/test/fixtures/abbrev-1.1.1.tgz
{CWD}/test/fixtures/abbrev-1.1.1.tgz
`

exports[`test/index.js TAP > tarball to file 1`] = `
Object {
"from": "file:test/fixtures/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
"resolved": "{CWD}/test/fixtures/abbrev-1.1.1.tgz",
}
`
6 changes: 3 additions & 3 deletions test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const { Minipass } = require('minipass')
const pkg = require('../package.json')
const bin = require.resolve(`../${pkg.bin.pacote}`)
const { main, run, parseArg, parse } = require(bin)
const cleanSnapshot = require('./helpers/clean-snapshot.js')

t.cleanSnapshot = str =>
str.split(pkg.version).join('{VERSION}')
.split(process.env.HOME).join('{HOME}')
t.cleanSnapshot = str => cleanSnapshot(str)
.split(pkg.version).join('{VERSION}')

const pacote = require('../')
pacote.resolve = (spec, conf) =>
Expand Down
Loading
Loading