Going from top to bottom, first task is version, it just gets the package version from package.json file and outputs it to the console. I use this in Jenkins.
Next comes clean. It just removes build generated files, for next build to start from a clean slate.
Next comes test. It does both unit testing and code coverage. This will generate test and code coverage reports, both on console using text and xml files to be used by jUnit and Cobertura plugins to generate nice graphs and reports in Jenkins.
Final three are watch, build, default. build is combo task that runs clean, lint, test and compile in that order. watch watches my files for changes and it triggers a new build automatically every time I make a change to my code. default task (which is triggered when you run gulp without passing any task) builds the projects and watches for file changes. This way I just type gulp and I’m ready to work on my project knowing that everything is good and every time I make a change it automatically will lint, test and compile my code.
This is the build cycle for this type of projects. All you need to do is have your repo url in publishConfig section of package.json file, auth info in .npmrc file and do npm publish. I use Nexus to host my private npms but you can use npmjs or something else.
Make sure to also check my other gulp files out: