16.07.2017 Views

AngularJS Essentials

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Automating the Workflow<br />

grunt.initConfig({<br />

clean: {<br />

dist: ["dist/"]<br />

}<br />

});<br />

grunt.loadNpmTasks("grunt-contrib-clean");<br />

}<br />

grunt.registerTask("dist", ["clean"]);<br />

In this case, we are creating our distribution package inside the dist/<br />

directory; however, you are free to choose another directory.<br />

2. Validating step: Now, it's time to configure the validation step. There<br />

is a plugin called grunt-contrib-jshint that can be installed with the<br />

following command:<br />

npm install grunt-contrib-jshint --save-dev<br />

Next, we need to configure it inside our Gruntfile.js file as follows:<br />

Gruntfile.js<br />

module.exports = function (grunt) {<br />

grunt.initConfig({<br />

clean: {<br />

dist: ["dist/"]<br />

},<br />

jshint: {<br />

all: ['Gruntfile.js', 'js/**/*.js', 'test/**/*.js']<br />

}<br />

});<br />

grunt.loadNpmTasks("grunt-contrib-clean");<br />

grunt.loadNpmTasks("grunt-contrib-jshint");<br />

}<br />

grunt.registerTask("dist", ["clean", "jshint"]);<br />

After we run this step, a report will be shown with the warnings and errors<br />

that it found in our code.<br />

[ 148 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!