Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mat committed Jun 5, 2015
1 parent 9c09e76 commit f26a578
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions tasks/angular-templates.js
Expand Up @@ -34,29 +34,29 @@ 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) {
compiled.push(compiler.compile(module, modules[module]));
}

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.');
}

Expand Down
6 changes: 3 additions & 3 deletions tasks/lib/compiler.js
Expand Up @@ -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;
}

Expand Down

0 comments on commit f26a578

Please sign in to comment.