How can I write my own terminal commands for an NPM project, which would replace the gulp
command without relying on npm run
?
My project contains the following Gulp and http-server custom commands...
## COMMANDS I CURRENTLY HAVE
| Command | Task |
|-----------------------|-----------------------------|
| npm run boom | "Builds then watches files" |
| npm run boom -- build | "Builds the assets files" |
| npm run launch | "Starts a local server" |
This is because of the scripts
in its package.json
file...
/// package.json
{
"scripts": {
"boom": "gulp",
"launch": "http-server -o"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-sass": "^2.1.0",
"http-server": "^0.8.5"
}
}
Here is what I would actually like my custom commands to be...
## COMMANDS I WANT TO HAVE
| Command | Task |
|-------------|-----------------------------|
| boom | "Builds then watches files" |
| boom build | "Builds the assets files" |
| boom launch | "Starts a local server" |
EDIT
"Can I add a debug script to NPM?" is not the same as what I am asking. I've already defined scripts in my package.json
file, which is how I ended up with my current commands. What I want is to write my own project commands/scripts that do the same things as what I have listed, without having to type npm run
.
Example
- I Currently Have
npm run boom
command
- What Does it Do?
- runs
gulp
command
- runs
- What Command Do I Want Available in the Project Instead, That Does the Same Thing?
boom
command