Get current directory path within a Grunt plugin using __dirname
If you need to refer to files within a grunt plugin you can use __dirname
.
I've used this to grab template files in a different directory within my grunt plugin, so that I can use them within the main task file.
e.g.
In this setup:
/grunt-plugin-PLUGIN_NAME
--/tasks
---- PLUGIN_NAME.js
--/templates
---- template.js
---- template.hbs
---- template.css
from a task within PLUGIN_NAME.js
you could retrieve the content of template.hbs with
var template = __dirname + '/../templates/template.hbs';