diff --git a/tasks/angular-templates.js b/tasks/angular-templates.js index 341d387..eb00e45 100644 --- a/tasks/angular-templates.js +++ b/tasks/angular-templates.js @@ -34,17 +34,17 @@ module.exports = function(grunt) { }); grunt.verbose.writeflags(options, 'Options'); - this.files.forEach(function(file) { - if (!file.src.length) { + if (!file.orig.src.length) { grunt.log.warn('No templates found'); } - options.module = file.module || options.module; - var cwd = grunt.option('cwd') || file.cwd; - console.log("CWD:", cwd); + options.module = grunt.option("module") || file.module || options.module; + var cwd = grunt.option('srccwd') || file.cwd; + var destcwd = grunt.option('destcwd') || file.destcwd; + console.log("CWD:", cwd, destcwd); var compiler = new Compiler(grunt, options, cwd); var appender = new Appender(grunt); - var modules = compiler.modules(file.src); + var modules = compiler.modules(file.orig.src); var compiled = []; for (var module in modules) { @@ -52,11 +52,11 @@ module.exports = function(grunt) { } if (options.append){ - fs.appendFileSync(path.join(cwd, file.dest), compiled.join('\n')); + fs.appendFileSync(path.join(destcwd, file.dest), compiled.join('\n')); grunt.log.writeln('File ' + file.dest.cyan + ' updated.'); } else{ - grunt.file.write(path.join(cwd, file.dest), compiled.join('\n')); + grunt.file.write(path.join(destcwd, file.dest), compiled.join('\n')); grunt.log.writeln('File ' + file.dest.cyan + ' created.'); } diff --git a/tasks/lib/compiler.js b/tasks/lib/compiler.js index 90a5d1e..122ba11 100644 --- a/tasks/lib/compiler.js +++ b/tasks/lib/compiler.js @@ -57,9 +57,9 @@ var Compiler = function(grunt, options, cwd) { * @return {String} Final template aggregate script */ this.compile = function(module, files) { - var paths = files.map(this.path).filter(function(path) { - if (!grunt.file.exists(path)) { - grunt.log.warn('Template "' + path + '" not found.'); + var paths = files.map(this.path).filter(function(obj) { + if (!grunt.file.exists(obj.path || obj)) { + grunt.log.warn('Template "' + obj + '" not found.'); return false; }