nps version: 5.10.0
node version: 12.16.1
npm version: 6.13.4
Scripts file (or at least the relevant bits):
module.exports = {
scripts: {
build: 'eleventy --input src --output dst',
develop: '$npm_package_scripts_build --serve',
test: 'echo "Error: no test specified" && exit 1'
}
};
The command executed:
The output:
nps is executing `develop` : $npm_package_scripts_build --serve
/bin/sh: --serve: command not found
The script called "develop" which runs "$npm_package_scripts_build --serve" failed with exit code 127 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code
Problem description:
npm allows templating in values from package.json; a script like $npm_package_scripts_build --serve would be expanded out to eleventy --input src --output dst --serve (given a build script of eleventy --input src --output dst). As nps init blows away the existing scripts, even if this variable were templated in it would not be valid.
Suggested solution:
Perhaps it could be enough to throw on init if one of these variables are found, since automatic conversion is not necessarily what you want. For instance, you could have a script like this:
{
"scripts": {
"version": "echo Current version: v$npm_package_version"
}
}
Capturing the version as a static value into your package-scripts.js on nps init is not equivalent here. 🙂
npsversion: 5.10.0nodeversion: 12.16.1npmversion: 6.13.4Scripts file (or at least the relevant bits):
The command executed:
nps developThe output:
Problem description:
npmallows templating in values frompackage.json; a script like$npm_package_scripts_build --servewould be expanded out toeleventy --input src --output dst --serve(given abuildscript ofeleventy --input src --output dst). Asnps initblows away the existing scripts, even if this variable were templated in it would not be valid.Suggested solution:
Perhaps it could be enough to throw on
initif one of these variables are found, since automatic conversion is not necessarily what you want. For instance, you could have a script like this:{ "scripts": { "version": "echo Current version: v$npm_package_version" } }Capturing the version as a static value into your
package-scripts.jsonnps initis not equivalent here. 🙂