mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
CLI class: added input file extension check
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user