Socket
Socket
Sign inDemoInstall

grunt-upx

Package Overview
Dependencies
100
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

tasks/bin/upx

0

Gruntfile.js

@@ -0,0 +0,0 @@ /*

22

package.json
{
"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

/*
* 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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc