Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-decomment

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-decomment - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

4

package.json
{
"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"));
});
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc