grunt-decomment
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "grunt-decomment", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Removes comments from JSON, JavaScript, CSS, HTML, etc.", | ||
@@ -37,5 +37,5 @@ "files": [ | ||
"cli-color": "1.1", | ||
"decomment": "^0.7.2" | ||
"decomment": "^0.7.4" | ||
}, | ||
"devDependencies": {} | ||
} |
@@ -46,4 +46,13 @@ grunt-decomment | ||
"output1.html": "input1.html", | ||
"index.html": "index.html" // rewrite the source file; | ||
"index.html": "index.html", // rewrite the source file; | ||
"./.tmp/index.html": "./.tmp/index.html" | ||
} | ||
}, | ||
withCwd: { | ||
options: { | ||
type: 'text' | ||
}, | ||
src: ['./*.css', './**/*.css', '!./vendor/**/*'], // array style with globs | ||
dest: './', // output folder | ||
cwd: './dist/' // current working directory | ||
} | ||
@@ -50,0 +59,0 @@ } |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var color = require('cli-color'); | ||
var path = require('path'); | ||
@@ -11,21 +12,12 @@ module.exports = function (grunt) { | ||
var files = this.files.map(function (f) { | ||
var result = { | ||
src: f.orig.src.length ? f.orig.src[0] : '', | ||
dest: f.dest | ||
}; | ||
if (grunt.file.exists(result.src)) { | ||
return result; | ||
} | ||
throw new Error("File '" + result.src + "' not found."); | ||
}); | ||
var type, method = 'decomment', opt = this.options(); | ||
var type, opt = this.options(); | ||
switch (opt.method) { | ||
switch (opt.type) { | ||
case 'text': | ||
type = decomment.text; | ||
method += '.text'; | ||
break; | ||
case 'html': | ||
type = decomment.html; | ||
method += '.html'; | ||
break; | ||
@@ -37,15 +29,24 @@ default: | ||
files.forEach(function (f) { | ||
var code = grunt.file.read(f.src); | ||
var result; | ||
try { | ||
result = type(code, opt); | ||
} catch (e) { | ||
grunt.log.writeln(f.src + " - " + color.redBright("FAIL")); | ||
throw e; | ||
} | ||
grunt.file.write(f.dest, result); | ||
grunt.log.writeln(f.src + " - " + color.green("OK")); | ||
this.files.forEach(function (byDest) { | ||
var cwd = byDest.cwd || ''; | ||
var dest = path.join(cwd, byDest.dest); | ||
byDest.src.forEach(function (f) { | ||
var file = path.join(cwd, f); | ||
var outFile = grunt.file.isDir(dest) ? path.join(dest, f) : dest; | ||
var code = grunt.file.read(file); | ||
var result; | ||
try { | ||
result = type(code, opt); | ||
} catch (e) { | ||
grunt.log.writeln(color.cyan(method + '(') + file + color.cyan(')') + ' - ' + color.redBright("FAIL")); | ||
throw e; | ||
} | ||
grunt.file.write(outFile, result); | ||
grunt.log.writeln(outFile + " - " + color.green("OK")); | ||
}) | ||
}); | ||
grunt.log.writeln(color.cyan(method + '()') + ' - ' + color.green("OK")); | ||
}); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5494
94
Updateddecomment@^0.7.4