CLI class: added input file extension check

This commit is contained in:
sanex3339
2016-06-25 20:16:33 +03:00
parent 4ecde19ab0
commit ca7c576041
2 changed files with 15 additions and 0 deletions
+11
View File
@@ -11,6 +11,13 @@ import { DEFAULT_PRESET } from "../preset-options/DefaultPreset";
import { JavaScriptObfuscator } from "../JavaScriptObfuscator";
export class JavaScriptObfuscatorCLI {
/**
* @type {string[]}
*/
private static availableInputExtensions: string[] = [
'.js'
];
/**
* @type {BufferEncoding}
*/
@@ -153,6 +160,10 @@ export class JavaScriptObfuscatorCLI {
throw new ReferenceError(`First argument must be a valid file path`);
}
if (JavaScriptObfuscatorCLI.availableInputExtensions.indexOf(path.extname(inputPath)) === -1) {
throw new ReferenceError(`Input file must have .js extension`);
}
return inputPath;
}