1.0.4 • Published 2 years ago
cross-params v1.0.4
Cross-params
This is an (over-)simplified solution for interpolating comand-line args for NPM scripts
Installation
npm:
npm install --save-dev cross-paramsyarn:
yarn add -D cross-paramsUsage
cross-params accepts command template as first argument, followed by actual command-line arguments. For example:
npx cross-params "yarn \${1}" --versionwill result in calling
yarn --versionThe syntax for template strings is following:
${n}wherenis the argument index starting from 1${key}wherekeyis the argument key in key-value pair.
--key=value or -k=value are consiedered as key-value arguments:
npx cross-params "yarn --\${command}" --command=versionNPM scripts
Note that you should wrap command template in quotes and escape the $ symbols:
// package.json
{
"scripts": {
"cross": "cross-params \"yarn \\${1}\""
}
}In this example you can run npm run cross --version, which will lead to calling yarn --version
Happy hacking!