Comparing version 0.0.4 to 0.0.5
30
index.js
@@ -8,3 +8,2 @@ | ||
const uglifyES = require('uglify-es') | ||
const uglifyJS = require('uglify-js') | ||
@@ -58,16 +57,23 @@ function getAllFiles(sourcePath, destPath, debug = false, ignoreRegex = undefined) { | ||
} | ||
let ast = esprima.parse(contents) | ||
let obfuscated = confusion.transformAst(ast, confusion.createVariableName) | ||
let confused = escodegen.generate(obfuscated) | ||
if (typeof (es) === 'boolean') { | ||
let resp = null; | ||
if (es === true) { | ||
resp = uglifyES.minify({ [filepath]: confused }, { warnings: true }) | ||
} else { | ||
resp = uglifyJS.minify({ [filepath]: confused }, { warnings: true }) | ||
if (es === true) { | ||
let opts = { | ||
warnings: debug, | ||
debug: debug, | ||
beautify: false, | ||
bracketize: true, | ||
compress: { | ||
drop_debugger: true, | ||
dead_code: true, | ||
passes: 2 | ||
} | ||
} | ||
let resp = uglifyES.minify({ [filepath]: confused }) | ||
if (resp.error) { | ||
throw resp.error | ||
} else if (resp.warnings) { | ||
console.warn(resp.warnings) | ||
console.warn(resp.warnings, filepath) | ||
} | ||
@@ -100,3 +106,3 @@ return resp.code | ||
} | ||
console.warn(`error while converting file ${file}`) | ||
console.warn(`error while converting file ${file} ${e.message}`) | ||
fs.copyFileSync(file, dpath) | ||
@@ -122,3 +128,3 @@ } | ||
.option('-e, --error [type]', 'throw error [true|false]', 'false') | ||
.option('-u, --uglify [type]', 'Use uglify, define type of js syntax [js|es|null]', 'es') | ||
.option('-u, --uglify [type]', 'Use uglify [true|false]', 'true') | ||
.option('-d, --debug [type]', 'Run in debug mode type of debug [false|true]', 'false') | ||
@@ -130,5 +136,5 @@ .option('-r, --ignore [ignoreRegexString]', 'Regex value to ignore files like ^[a-zA-Z0-9_]+\.js', '') | ||
.action(function (src, dest) { | ||
if (program.uglify == 'es') { | ||
if (program.uglify == 'true') { | ||
program.uglify = true; | ||
} else if (program.uglify == 'js') { | ||
} else { | ||
program.uglify = false; | ||
@@ -135,0 +141,0 @@ } |
{ | ||
"name": "contego", | ||
"version": "0.0.4", | ||
"description": "simple code protect for javascript files", | ||
"version": "0.0.5", | ||
"description": "Simple code protect for javascript files", | ||
"main": "index.js", | ||
@@ -24,10 +24,9 @@ "scripts": {}, | ||
"dependencies": { | ||
"commander": "^2.14.1", | ||
"confusion": "^0.1.1", | ||
"escodegen": "^1.9.1", | ||
"esprima": "^4.0.0", | ||
"fs-extra": "^5.0.0", | ||
"uglify-es": "^3.3.9", | ||
"uglify-js": "^3.3.13" | ||
"commander": "2.14.1", | ||
"confusion": "0.1.1", | ||
"escodegen": "1.9.1", | ||
"esprima": "4.0.0", | ||
"fs-extra": "5.0.0", | ||
"uglify-es": "3.3.9" | ||
} | ||
} |
@@ -14,4 +14,4 @@ | ||
- dest dir = destination directory | ||
- -u = use uglify, es for es6 files, js for es5 or below and null for skipping uglify | ||
- -d = debug mode, for extra logging | ||
- -u = use uglify, true or false | ||
- -d = debug mode,true or false for extra logging | ||
- -i = ignore regex string, provide regex to ignore any files define by user | ||
@@ -18,0 +18,0 @@ |
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
6
142
6346
+ Addedcommander@2.13.0(transitive)
+ Addedescodegen@1.9.1(transitive)
+ Addedesprima@3.1.34.0.0(transitive)
+ Addeduglify-es@3.3.9(transitive)
- Removeduglify-js@^3.3.13
- Removedcommander@2.20.3(transitive)
- Removedescodegen@1.14.3(transitive)
- Removedesprima@4.0.1(transitive)
- Removeduglify-es@3.3.10(transitive)
- Removeduglify-js@3.19.3(transitive)
Updatedcommander@2.14.1
Updatedconfusion@0.1.1
Updatedescodegen@1.9.1
Updatedesprima@4.0.0
Updatedfs-extra@5.0.0
Updateduglify-es@3.3.9