Quickly test drive the creation of a Grunt plugin. Part 3.

Code from screencast and tutorial is available on Github.
The screencast has more detail and explanation than this tutorial.

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.

We have a problem with the way the reload.js.tpl file is being read. The path tasks/reload.js.tpl works fine when locally developing this plugin but how about when it is included in another extension project. The tasks/reload.js.tpl path 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.tpl let's tap into Nodejs' path.resolve.

Edit tasks/crx_auto_load.js adding the code within the gray highlighted sections:

Run the tests again to make sure we're green.

The reload.js file only needs to be created on the first run. Add the highlighted code to tasks/crx_auto_load.js.

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.

Conclusion

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 watchthescreencasts if want more details and commentary.
.