Skip to content

Commit

Permalink
Support npm >= 7 through RFC'd config section
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Mar 20, 2022
1 parent 9768f14 commit b736870
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
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'
}

0 comments on commit b736870

Please sign in to comment.