From 389d4b6bc51c3f3ec290e4fd096e07dcc2923e95 Mon Sep 17 00:00:00 2001 From: Amr Draz Date: Sat, 20 Jun 2015 03:44:33 +0300 Subject: [PATCH] Bug Fix for undefined I would get ``` Warning: Cannot read property 'forEach' of undefined Use --force to continue. TypeError: Cannot read property 'forEach' of undefined at Object. (/node_modules/grunt-purifycss/tasks/purifycss.js:22:18) . . ``` and then the task would stop looking at the grunt API I noticed that data simply returns the object value I passed in my config which if according to the example is inside data.target not the data object itself using grunt 0.4.5 (but I got that from the latest documentation for the API --- tasks/purifycss.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/purifycss.js b/tasks/purifycss.js index aabaef1..aea761f 100644 --- a/tasks/purifycss.js +++ b/tasks/purifycss.js @@ -19,14 +19,14 @@ module.exports = function(grunt) { }); var src = []; - this.data.src.forEach(function(pathPattern) { + this.data.target.src.forEach(function(pathPattern) { var files = glob.sync(pathPattern); console.log("Source Files: ", files); src = src.concat(files); }); var styles = []; - this.data.css.forEach(function(pathPattern) { + this.data.target.css.forEach(function(pathPattern) { var style = glob.sync(pathPattern); console.log("Style Files: ", style); styles = styles.concat(style); @@ -34,7 +34,7 @@ module.exports = function(grunt) { var pure = purify(src, styles, {write: false, info: true}); - grunt.file.write(this.data.dest, pure); + grunt.file.write(this.data.target.dest, pure); grunt.log.writeln('File "' + this.data.dest + '" created.'); });