Commits

Kazunori Ninomiya  committed 4a7e9da

bug fix

  • Participants
  • Parent commits 346cfe0

Comments (0)

Files changed (1)

File tasks/ect.js

       , done = this.async()
       ;
 
-    if (grunt.util.kindOf(options.watch) !== 'undefined') {
+    if (typeof options.watch !== 'undefined') {
       delete options['watch'];
     }
 
 
     this.files.forEach(function(f) {
       try {
-        var validFiles = removeInvalidFiles(f);
+        var validFiles = removeInvalidFiles(getSrc(f, options));
         writeFile(f.dest, concatOutput(validFiles, options));
       }
       catch (e) {
     done(true);
   });
 
+  function getSrc(file, options)
+  {
+    var result
+      , src = file.src
+      ;
+
+    if (typeof file.cwd === 'undefined'
+      && typeof options.root !== 'undefined'
+    ) {
+      file.cwd = options.root;
+      result = grunt.file.expandMapping(file.orig.src, null, {
+        cwd: file.cwd,
+        flatten: file.flatten,
+        ext: file.ext,
+      });
+
+      if (result.length > 0) {
+        src = result[0].src;
+      }
+    }
+
+    return src;
+  }
+
   function removeInvalidFiles(files)
   {
-    return files.src.filter(function(filepath) {
+    return files.filter(function(filepath) {
       if (!grunt.file.exists(filepath)) {
         grunt.log.warn('Source file "' + filepath + '" not found."');
         return false;
     var renderer, root;
 
     options = _.clone(options);
-    if (grunt.util.kindOf(options.root) === 'undefined') {
+    if (typeof options.root === 'undefined') {
       options.root = path.dirname(filepath);
       filepath = path.basename(filepath);
     }