Grunt.js manipulate parent directory
Question
I'm trying to make a build structure where files aren't just "floating about".
The reason for this is that I'm using Drupal and don't want to have the gruntfile, package.json and "node_modules"-folder placed loosely in the "themes"-folder.
My desired file structure:
- sites
- all
- themes
- grunt_environment
- Gruntfile.coffee
- node_modules
- src
- package.json
- theme_name
- theme_name.info
I'm using grunt-contrib-clean
and want to clean up my "theme_name"-folder each time I re-build my project. Unfortunately I get the following message:
Warning: Cannot delete files outside the current working directory. Use --force to continue.
So I guess my options are: 1 - Live with the fact that files are "floating about" in the themes folder. 2 - Find another way of structuring my files 3 - Clean the folder manually
or (what I hope for):
4 - Set an option to allow certain folders to be deleted by the grunt-contrib-clean
module.
So - I'd really like to go with the 4th option, but the 2nd could do if anyone has a clever way of structuring my files.
Anyone who's experienced and overcome a similar structuring problem when working with Drupal (or Wordpress for that matter?)
Thanks in advance.
Solution
Set the force
option of grunt-contrib-clean
to true
to delete files outside of your current working directory. It avoids deleting outside the cwd
to avoid accidentally deleting your entire system.
clean:
options: force: true
A better option, IMO, is to put the Gruntfile.coffee
, node_modules
, and package.json
at the base of your project.