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

fix: prepare script respects scriptshell config #389

Closed
wants to merge 1 commit into from
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
1 change: 1 addition & 0 deletions lib/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DirFetcher extends Fetcher {
const stdio = this.opts.foregroundScripts ? 'inherit' : 'pipe'

return runScript({
scriptShell: this.opts.scriptShell || undefined,
pkg: mani,
event: 'prepare',
path: this.resolved,
Expand Down
66 changes: 66 additions & 0 deletions tap-snapshots/test/dir.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,69 @@ Object {
},
}
`

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

exports[`test/dir.js TAP with prepare script with scriptshell configuration > file list 1`] = `
Array [
"index.js",
"package.json",
"prepare.js",
]
`

exports[`test/dir.js TAP with prepare script with scriptshell configuration > manifest 1`] = `
Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
"license": "ISC",
"main": "index.js",
"name": "git-prepare-script",
"scripts": Object {
"prepare": "node prepare.js",
},
"version": "1.0.0",
}
`

exports[`test/dir.js TAP with prepare script with scriptshell configuration > packument 1`] = `
Object {
"dist-tags": Object {
"latest": "1.0.0",
},
"name": "git-prepare-script",
"versions": Object {
"1.0.0": Object {
"_from": "file:test/fixtures/prepare-script",
"_id": "[email protected]",
"_integrity": null,
"_resolved": "\${CWD}/test/fixtures/prepare-script",
"devDependencies": Object {
"abbrev": "^1.1.1",
},
"dist": Object {
"integrity": null,
"tarball": "file:\${CWD}/test/fixtures/prepare-script",
},
"license": "ISC",
"main": "index.js",
"name": "git-prepare-script",
"scripts": Object {
"prepare": "node prepare.js",
},
"version": "1.0.0",
},
},
}
`
16 changes: 16 additions & 0 deletions test/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ t.test('with prepare script', async t => {
}, 'should run in background'))
})

t.test('with prepare script with scriptshell configuration', async t => {
RUNS.length = 0
const f = new DirFetcher(preparespec, { tree: await loadActual(prepare), scriptShell: 'sh' })
t.resolveMatchSnapshot(f.packument(), 'packument')
t.resolveMatchSnapshot(f.manifest(), 'manifest')
const index = me + '/prepare/index.js'
return t.resolveMatchSnapshot(f.extract(me + '/prepare'), 'extract')
.then(() => t.spawn(process.execPath, [index], 'test prepared result'))
.then(() => t.matchSnapshot(fs.readdirSync(me + '/prepare').sort(), 'file list'))
.then(() => t.match(RUNS,
[{
stdio: 'pipe',
scriptShell: 'sh',
}], 'should run in background and use scriptshell configuration'))
})

t.test('responds to foregroundScripts: true', async t => {
RUNS.length = 0
const opt = { foregroundScripts: true, tree: await loadActual(prepare) }
Expand Down