grunt-upx
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -0,0 +0,0 @@ /* |
{ | ||
"name": "grunt-upx", | ||
"description": "By using upx.exe this plugin is able to compress executables files up to 85% of their original size.", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"homepage": "https://github.com/pirumpi/grunt-upx", | ||
@@ -18,8 +18,6 @@ "author": { | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/pirumpi/grunt-upx/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"licenses": [{ | ||
"type": "MIT", | ||
"url": "https://github.com/pirumpi/grunt-upx/blob/master/LICENSE-MIT" | ||
}], | ||
"engines": { | ||
@@ -32,9 +30,9 @@ "node": ">= 0.8.0" | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "^0.9.2", | ||
"grunt-contrib-clean": "^0.5.0", | ||
"grunt-contrib-nodeunit": "^0.3.3", | ||
"grunt": "~0.4.5" | ||
"grunt-contrib-jshint": ">=0.9.2", | ||
"grunt-contrib-clean": ">=0.5.0", | ||
"grunt-contrib-nodeunit": ">=0.3.3", | ||
"grunt": ">=0.4.5" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "~0.4.5" | ||
"grunt": ">=0.4.5" | ||
}, | ||
@@ -41,0 +39,0 @@ "keywords": [ |
@@ -0,0 +0,0 @@ # grunt-upx |
166
tasks/upx.js
/* | ||
* grunt-upx | ||
* https://github.com/pirumpi/grunt-upx | ||
* | ||
* Copyright (c) 2015 Carlos Martin | ||
* Licensed under the MIT license. | ||
*/ | ||
* grunt-upx | ||
* https://github.com/pirumpi/grunt-upx | ||
* | ||
* Copyright (c) 2015 Carlos Martin | ||
* Licensed under the MIT license. | ||
*/ | ||
'use strict'; | ||
"use strict"; | ||
var exec = require('child_process').exec; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var upx = path.resolve('node_modules','grunt-upx','tasks', 'bin', 'upx.exe'); | ||
var exec = require("child_process").exec; | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var upx = path.resolve( | ||
"node_modules", | ||
"grunt-upx", | ||
"tasks", | ||
"bin", | ||
process.platform == "win32" ? "upx.exe" : "upx" | ||
); | ||
module.exports = function(grunt) { | ||
// Please see the Grunt documentation for more information regarding task | ||
// creation: http://gruntjs.com/creating-tasks | ||
grunt.registerMultiTask('upx', 'By using upx.exe this plugin is able to compress executables files up to 85% of their original size.', function() { | ||
// Merge task-specific and/or target-specific options with these defaults. | ||
var done = this.async(); | ||
var options = this.options({ | ||
speed: 3, | ||
args: '' | ||
}); | ||
var data = this.data; | ||
var fileList = []; | ||
var destFolder = data.files.dest ? path.resolve(data.files.dest) : null; | ||
grunt.registerMultiTask( | ||
"upx", | ||
"By using upx this plugin is able to compress executables files up to 85% of their original size.", | ||
function() { | ||
// Merge task-specific and/or target-specific options with these defaults. | ||
var done = this.async(); | ||
var options = this.options({ | ||
speed: 3, | ||
args: "" | ||
}); | ||
var data = this.data; | ||
var fileList = []; | ||
var destFolder = data.files.dest ? path.resolve(data.files.dest) : null; | ||
function error(str, grunt, done) { | ||
grunt.log.write(str); | ||
done(false); | ||
} | ||
var compressFiles = function(done, options, grunt){ | ||
if(fileList.length){ | ||
var file = fileList.shift(); | ||
grunt.log.writeln('compressing ' + file); | ||
exec(upx + options.args + ' -' + options.speed + ' ' + file, function(err, stdout, stderr){ | ||
if(!err){ | ||
compressFiles(done, options, grunt); | ||
grunt.log.write(stdout); | ||
}else{ | ||
error(err, grunt, done); | ||
} | ||
}); | ||
}else{ | ||
done(true); | ||
function error(str, grunt, done) { | ||
grunt.log.write(str); | ||
done(false); | ||
} | ||
}; | ||
grunt.event.once('filesCreated', function(){ | ||
compressFiles(done, options, grunt); | ||
}); | ||
grunt.event.once('folderChecked',function(){ | ||
grunt.log.writeln('Checking files'); | ||
data.files.src.forEach(function(f){ | ||
if(destFolder !== null){ | ||
var movedFile = path.resolve(destFolder, path.basename(f)); | ||
fs.writeFileSync(movedFile, fs.readFileSync(f)); | ||
fileList.push(movedFile); | ||
}else{ | ||
fileList.push(f); | ||
} | ||
grunt.log.writeln('file copied'); | ||
}); | ||
grunt.event.emit('filesCreated'); | ||
}); | ||
if(destFolder !== null){ | ||
fs.exists(destFolder, function(exist){ | ||
if(!exist){ | ||
fs.mkdir(destFolder, function(err){ | ||
if(!err){ | ||
grunt.event.emit('folderChecked'); | ||
}else{ | ||
var compressFiles = function(done, options, grunt) { | ||
if (fileList.length) { | ||
var file = fileList.shift(); | ||
grunt.log.writeln("compressing " + file); | ||
exec(upx + options.args + " -" + options.speed + " " + file, function( | ||
err, | ||
stdout, | ||
stderr | ||
) { | ||
if (!err) { | ||
compressFiles(done, options, grunt); | ||
grunt.log.write(stdout); | ||
} else { | ||
error(err, grunt, done); | ||
} | ||
grunt.log.writeln('folder created'); | ||
}); | ||
}else{ | ||
grunt.event.emit('folderChecked'); | ||
grunt.log.writeln('folder created'); | ||
} else { | ||
done(true); | ||
} | ||
}; | ||
grunt.event.once("filesCreated", function() { | ||
compressFiles(done, options, grunt); | ||
}); | ||
}else{ | ||
grunt.log.writeln('no destination folder found'); | ||
grunt.event.emit('folderChecked'); | ||
} | ||
}); | ||
grunt.event.once("folderChecked", function() { | ||
grunt.log.writeln("Checking files"); | ||
data.files.src.forEach(function(f) { | ||
if (destFolder !== null) { | ||
var movedFile = path.resolve(destFolder, path.basename(f)); | ||
fs.writeFileSync(movedFile, fs.readFileSync(f)); | ||
fileList.push(movedFile); | ||
} else { | ||
fileList.push(f); | ||
} | ||
grunt.log.writeln("file copied"); | ||
}); | ||
grunt.event.emit("filesCreated"); | ||
}); | ||
if (destFolder !== null) { | ||
fs.exists(destFolder, function(exist) { | ||
if (!exist) { | ||
fs.mkdir(destFolder, function(err) { | ||
if (!err) { | ||
grunt.event.emit("folderChecked"); | ||
} else { | ||
error(err, grunt, done); | ||
} | ||
grunt.log.writeln("folder created"); | ||
}); | ||
} else { | ||
grunt.event.emit("folderChecked"); | ||
grunt.log.writeln("folder created"); | ||
} | ||
}); | ||
} else { | ||
grunt.log.writeln("no destination folder found"); | ||
grunt.event.emit("folderChecked"); | ||
} | ||
} | ||
); | ||
}; |
@@ -0,0 +0,0 @@ 'use strict'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
917275
193