Quickly test drive the creation of a Grunt plugin. Part 3.
Regards ♨ – Minimul
Continuing from Part 2 and finishing up
In Part 2, I implemented a template to render the
reload.js file that properly referenced
reload.html. In this latest installment we will finish and publish the plugin.
tasks/crx_auto_load.jsadding the code within the gray highlighted sections:
- The reload.js file only needs to be created on the first run. Add the highlighted code to
- Write an informative README
- Before publishing as a NPM package create a new Github repo and push to it. The Yeoman gruntplugin generator provides a nice .gitignore so you can just do:
- Now let's publish the plugin. If you don't have one, create a new NPM account.
- That's it, the Grunt plugin is now live at npmjs.org.
reload.js.tplfile is being read. The path
tasks/reload.js.tplworks fine when locally developing this plugin but how about when it is included in another extension project. The
tasks/reload.js.tplpath is relative to the Gruntfile so this will fail when running a grunt task from a project with another Gruntfile. We need a way to generate the absolute path to
tasks/reload.js.tpl. To generate an absolute path to
tasks/reload.js.tpllet's tap into Nodejs'
# For example $ git init $ git add . $ git commit -am "Initial commit" $ git remote add origin email@example.com:minimul/grunt-crx-auto-reload.git $ git push origin master
$ npm adduser Username: minimul Password: ******* Email: (this IS public) firstname.lastname@example.org npm http PUT https://registry.npmjs.org/-/user/org.couchdb.user:minimul npm http 201 https://registry.npmjs.org/-/user/org.couchdb.user:minimul $ npm publish npm http PUT https://registry.npmjs.org/grunt-crx-auto-reload npm http 201 https://registry.npmjs.org/grunt-crx-auto-reload + email@example.com
Aftering updating the plugin you must bump the version number in
package.json and then issue another
npm publish. Be sure to follow semantic versioning.
Yeah, it wasn't exactly rocket science but it should save you a bunch of time getting a new Grunt plugin off the ground if you are new to the ecosystem. Remember to watch the screencasts if want more details and commentary. .