reputationdefender / grunt-clean

grunt task to remove previously generated files and directories
MIT License
11 stars 6 forks source link

Update tasks/clean.js #3

Closed hitsthings closed 12 years ago

hitsthings commented 12 years ago

I misunderstood the config structure and accidentally passed in a config like:

clean : {     output : { folder: 'path' },     otherDir : { folder: 'other/path' } }

Since path.resolve([Object object]) => cwd, I ended up half-deleting my .git and had to manually reclone and patch my changes in.

This fix at least checks that you're passing in the correct data before deleting things.

Another good fix might be to check for '.git', '.hg', or maybe just any '.' folders and cancel the clean (maybe add a force: true option to override).

Anyway, that fix is more opinionated, so I didn't make it. But at least this one will save people from cleaning things they didn't mean to. :)

hitsthings commented 12 years ago

I think my patch was fail anyway. I check for a non-existant "path" variable instead of the 'p' parameter that is passed in. So at least needs a tweak and a bit of QA before it should be released.