Node.js | Automation With onsave
This package, onsave, aims to be the simplest most beginer friendly npm package for automating command line tasks.
Full disclosure I just finished creating the npm package, onsave, here are the links.
https://github.com/orgs/onsave
This article will serve as a quick start tutorial.
Make a package.json:
npm init -y
Install onsave:
npm install -D onsave
create a file (if you dont know how to use vim use your prefered text editor);
vim helloWorld.js
Enter some code
File Name: helloWorld.js
console.log('hello')
Setup a listener to automatically execute the file you have created each time you save.
npx onsave helloWorld.js node helloWorld.js
Now save the file helloWorld.js it may not respond until the second time you save and then each time after that.
You will see
hello
printed to the console each time you save.
Now edit your helloWorld.js file to:
File Name: helloWorld.js
console.log('hello world');
Now each time you save the file you will see
hello world
printed out the console.
You can use any commands you like and they will be executed when your chosen file is saved.
Thanks for checking out onsave.