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

Support npm >= 7 through RFC'd config section #105

Merged
merged 1 commit into from
Apr 6, 2022
Merged
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
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ Finally, if you **always** want to run scripts in parallel, any option can be
set in your package.json under a `"scripty"` entry:

```json
"scripty": {
"parallel": true
"config": {
"scripty": {
"parallel": true
}
}
```

Expand Down Expand Up @@ -203,9 +205,11 @@ If you'd like to customize the base directories scripty uses to search for your
scripts, add a `"scripty"` object property to your package.json like so:

``` json
"scripty": {
"path": "../core/scripts",
"windowsPath": "../core/scripts-win"
"config": {
"scripty": {
"path": "../core/scripts",
"windowsPath": "../core/scripts-win"
}
}
```

Expand All @@ -221,8 +225,10 @@ for your scripts and then share them across multiple projects. To include module
add a `"scripty"` object property, `modules`, to your package.json like so:

``` json
"scripty": {
"modules": ["packageA", "packageB"]
"config": {
"scripty": {
"modules": ["packageA", "packageB"]
}
}
```

Expand Down Expand Up @@ -266,8 +272,10 @@ Worth mentioning, like all options this can be set in package.json under a
`"scripty"` entry:

```json
"scripty": {
"dryRun": true
"config": {
"scripty": {
"dryRun": true
}
}
```

Expand All @@ -288,8 +296,10 @@ If you always want scripty to run your scripts at a certain level,
you can set it in your package.json under a `"scripty"` entry:

```json
"scripty": {
"logLevel": "warn"
"config": {
"scripty": {
"logLevel": "warn"
}
}
```

Expand Down
8 changes: 7 additions & 1 deletion lib/load-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module.exports = function loadOption (name) {
return boolEnvVarValue(posixEnvVarName(name))
} else if (envVarSet(packageEnvVarName(name))) {
return boolEnvVarValue(packageEnvVarName(name))
} else if (envVarSet(packageEnvConfigVarName(name))) {
return boolEnvVarValue(packageEnvConfigVarName(name))
} else if (envVarSet(packageArrayEnvVarName(name))) {
return arrayEnvVarValue(packageEnvVarName(name))
}
Expand Down Expand Up @@ -42,10 +44,14 @@ function posixEnvVarName (optionName) {
return 'SCRIPTY_' + _.snakeCase(optionName).toUpperCase()
}

function packageEnvVarName (optionName) {
function packageEnvVarName (optionName) { // Backwards compatible for npm v6
return 'npm_package_scripty_' + optionName
}

function packageEnvConfigVarName (optionName) {
return 'npm_package_config_scripty_' + optionName
}

function packageArrayEnvVarName (optionName) {
return packageEnvVarName(optionName) + '_0'
}