Skip to content

Allow script-shell config in package.json #36

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

Closed
wants to merge 1 commit into from
Closed
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
54 changes: 54 additions & 0 deletions accepted/0000-package-json-script-shell-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Allow [`script-shell`] config in `package.json`

## Summary

Add the ability to configure [`script-shell`] directly in `package.json`.

## Motivation

It would be useful to be able to specify the [`script-shell`] config option somewhere in `package.json`, without having to have a separate one-line `.npmrc` just for this.

## Detailed Explanation

Following on from https://github.com/npm/npm/issues/20336, and as mentioned in https://github.com/npm/npm/pull/16687#issuecomment-315263454, this is a simple proposal to allow [`script-shell`] to be configured directly in `package.json`. Currently this option can be set in `.npmrc`, but this forces an extra file which otherwise might not be necessary.

~~~ ini
# .npmrc
script-shell = /bin/bash
~~~

## Rationale and Alternatives

The ability to configure the [`script-shell`] option in `package.json` would alleviate the need to have a separate one-line `.npmrc` just for this. Additionally, being able to configure a different [`script-shell`] based on the platform, perhaps mirroring the [`os` key], would also be useful.

## Implementation

Something like:
~~~ js
// package.json
"script-shell": "/bin/bash",
// or
"script-shell": {
"!win32": "/bin/bash",
"win32": "c:\Program Files\git\bin\bash.exe"
},
~~~

## Unresolved Questions and Bikeshedding

The config option could alternatively be defined under the [`scripts`] object:
~~~ js
// package.json
"scripts": {
"shell": "/bin/bash",
// or
"shell": {
"!win32": "/bin/bash",
"win32": "c:\Program Files\git\bin\bash.exe"
}
},
~~~

[`os` key]: https://docs.npmjs.com/files/package.json#os
[`script-shell`]: https://docs.npmjs.com/cli/run-script#description
[`scripts`]: https://docs.npmjs.com/files/package.json#scripts