|
@@ -1145,21 +1145,8 @@ var CLIUtils = function () {
|
|
}
|
|
}
|
|
|
|
|
|
_createClass(CLIUtils, null, [{
|
|
_createClass(CLIUtils, null, [{
|
|
- key: 'getInputPath',
|
|
|
|
- value: function getInputPath(argv) {
|
|
|
|
- var inputPath = argv[0];
|
|
|
|
- if (!CLIUtils.isFilePath(inputPath)) {
|
|
|
|
- throw new ReferenceError('First argument must be a valid file path');
|
|
|
|
- }
|
|
|
|
- if (!Utils_1.Utils.arrayContains(CLIUtils.availableInputExtensions, path.extname(inputPath))) {
|
|
|
|
- throw new ReferenceError('Input file must have .js extension');
|
|
|
|
- }
|
|
|
|
- return inputPath;
|
|
|
|
- }
|
|
|
|
- }, {
|
|
|
|
key: 'getOutputCodePath',
|
|
key: 'getOutputCodePath',
|
|
- value: function getOutputCodePath(commands, inputPath) {
|
|
|
|
- var outputPath = commands.output;
|
|
|
|
|
|
+ value: function getOutputCodePath(outputPath, inputPath) {
|
|
if (outputPath) {
|
|
if (outputPath) {
|
|
return outputPath;
|
|
return outputPath;
|
|
}
|
|
}
|
|
@@ -1193,6 +1180,16 @@ var CLIUtils = function () {
|
|
value: function readFile(inputPath) {
|
|
value: function readFile(inputPath) {
|
|
return fs.readFileSync(inputPath, CLIUtils.encoding);
|
|
return fs.readFileSync(inputPath, CLIUtils.encoding);
|
|
}
|
|
}
|
|
|
|
+ }, {
|
|
|
|
+ key: 'validateInputPath',
|
|
|
|
+ value: function validateInputPath(inputPath) {
|
|
|
|
+ if (!CLIUtils.isFilePath(inputPath)) {
|
|
|
|
+ throw new ReferenceError('Given input path must be a valid file path');
|
|
|
|
+ }
|
|
|
|
+ if (!Utils_1.Utils.arrayContains(CLIUtils.availableInputExtensions, path.extname(inputPath))) {
|
|
|
|
+ throw new ReferenceError('Input file must have .js extension');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}, {
|
|
}, {
|
|
key: 'writeFile',
|
|
key: 'writeFile',
|
|
value: function writeFile(outputPath, data) {
|
|
value: function writeFile(outputPath, data) {
|
|
@@ -1247,7 +1244,8 @@ var JavaScriptObfuscatorCLI = function () {
|
|
this.commands.outputHelp();
|
|
this.commands.outputHelp();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- this.inputPath = CLIUtils_1.CLIUtils.getInputPath(this.arguments);
|
|
|
|
|
|
+ this.inputPath = this.arguments[0];
|
|
|
|
+ CLIUtils_1.CLIUtils.validateInputPath(this.inputPath);
|
|
this.getData();
|
|
this.getData();
|
|
this.processData();
|
|
this.processData();
|
|
}
|
|
}
|
|
@@ -1289,7 +1287,7 @@ var JavaScriptObfuscatorCLI = function () {
|
|
key: 'processData',
|
|
key: 'processData',
|
|
value: function processData() {
|
|
value: function processData() {
|
|
var options = this.buildOptions(),
|
|
var options = this.buildOptions(),
|
|
- outputCodePath = CLIUtils_1.CLIUtils.getOutputCodePath(this.commands, this.inputPath);
|
|
|
|
|
|
+ outputCodePath = CLIUtils_1.CLIUtils.getOutputCodePath(this.commands.output, this.inputPath);
|
|
if (options.sourceMap) {
|
|
if (options.sourceMap) {
|
|
this.processDataWithSourceMap(outputCodePath, options);
|
|
this.processDataWithSourceMap(outputCodePath, options);
|
|
} else {
|
|
} else {
|