mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Merge branch 'dev'
This commit is contained in:
@@ -5,6 +5,7 @@ v0.10.0
|
||||
* **New option:** `deadCodeInjection`. With this option random blocks of dead code will add to the obfuscated code.
|
||||
* **New option:** `deadCodeInjectionThreshold` allows to set percentage of nodes that will affected by `deadCodeInjection`.
|
||||
* **New option:** `mangle` enables mangling of variable names.
|
||||
* **New CLI option:** `--config` allows to set config file with obfuscator options.
|
||||
* **Breaking change:** `disableConsoleOutput` option now disabled by default.
|
||||
* **Breaking change:** `escapeUnicodeSequence` option now disabled by default.
|
||||
* `controlFlowFlattening` now affects string literal nodes.
|
||||
|
||||
@@ -269,7 +269,7 @@ Compact code output on one line.
|
||||
### `config`
|
||||
Type: `string` Default: ``
|
||||
|
||||
Name of JS/JSON config file which contains options mentioned above. These will be overridden by options passed directly to CLI
|
||||
Name of JS/JSON config file which contains obfuscator options. These will be overridden by options passed directly to CLI
|
||||
|
||||
### `controlFlowFlattening`
|
||||
Type: `boolean` Default: `false`
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -50,6 +50,29 @@ export class JavaScriptObfuscatorCLI {
|
||||
this.commands = <commander.CommanderStatic>(new commander.Command());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param options
|
||||
* @returns {TInputOptions}
|
||||
*/
|
||||
private static sanitizeOptions (options: {[key: string]: any}): TInputOptions {
|
||||
const filteredOptions: TInputOptions = {};
|
||||
const availableOptions: string[] = Object.keys(DEFAULT_PRESET);
|
||||
|
||||
for (const option in options) {
|
||||
if (!options.hasOwnProperty(option)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!availableOptions.includes(option)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(<any>filteredOptions)[option] = (<any>options)[option];
|
||||
}
|
||||
|
||||
return filteredOptions;
|
||||
}
|
||||
|
||||
public run (): void {
|
||||
this.configureCommands();
|
||||
this.configureHelp();
|
||||
@@ -71,11 +94,13 @@ export class JavaScriptObfuscatorCLI {
|
||||
* @returns {TInputOptions}
|
||||
*/
|
||||
private buildOptions (): TInputOptions {
|
||||
const inputOptions: TInputOptions = this.sanitizeOptions(this.commands);
|
||||
const configFileLocation: string = this.commands.config ?
|
||||
path.resolve(this.commands.config, '.') : '';
|
||||
const configFileOptions: TInputOptions = configFileLocation ?
|
||||
this.sanitizeOptions(require(configFileLocation)) : {};
|
||||
const inputOptions: TInputOptions = JavaScriptObfuscatorCLI.sanitizeOptions(this.commands);
|
||||
const configFileLocation: string = this.commands.config
|
||||
? path.resolve(this.commands.config, '.')
|
||||
: '';
|
||||
const configFileOptions: TInputOptions = configFileLocation
|
||||
? JavaScriptObfuscatorCLI.sanitizeOptions(require(configFileLocation))
|
||||
: {};
|
||||
|
||||
return {
|
||||
...DEFAULT_PRESET,
|
||||
@@ -84,24 +109,6 @@ export class JavaScriptObfuscatorCLI {
|
||||
};
|
||||
}
|
||||
|
||||
private sanitizeOptions (options: any): TInputOptions {
|
||||
const filteredOptions: TInputOptions = {};
|
||||
const availableOptions: string[] = Object.keys(DEFAULT_PRESET);
|
||||
|
||||
for (const option in options) {
|
||||
if (!options.hasOwnProperty(option)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!availableOptions.includes(option)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(<any>filteredOptions)[option] = (<any>options)[option];
|
||||
}
|
||||
return filteredOptions;
|
||||
}
|
||||
|
||||
private configureCommands (): void {
|
||||
this.commands
|
||||
.version(CLIUtils.getPackageConfig().version, '-v, --version')
|
||||
|
||||
Reference in New Issue
Block a user