|
@@ -2,6 +2,7 @@ import * as commander from 'commander';
|
|
import * as path from 'path';
|
|
import * as path from 'path';
|
|
|
|
|
|
import { TInputOptions } from '../types/options/TInputOptions';
|
|
import { TInputOptions } from '../types/options/TInputOptions';
|
|
|
|
+import { TObject } from '../types/TObject';
|
|
|
|
|
|
import { IObfuscationResult } from '../interfaces/IObfuscationResult';
|
|
import { IObfuscationResult } from '../interfaces/IObfuscationResult';
|
|
|
|
|
|
@@ -51,23 +52,19 @@ export class JavaScriptObfuscatorCLI {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @param {Object} options
|
|
|
|
|
|
+ * @param {TObject} options
|
|
* @returns {TInputOptions}
|
|
* @returns {TInputOptions}
|
|
*/
|
|
*/
|
|
- private static sanitizeOptions (options: Object): TInputOptions {
|
|
|
|
|
|
+ private static sanitizeOptions (options: TObject): TInputOptions {
|
|
const filteredOptions: TInputOptions = {};
|
|
const filteredOptions: TInputOptions = {};
|
|
const availableOptions: string[] = Object.keys(DEFAULT_PRESET);
|
|
const availableOptions: string[] = Object.keys(DEFAULT_PRESET);
|
|
|
|
|
|
for (const option in options) {
|
|
for (const option in options) {
|
|
- if (!options.hasOwnProperty(option)) {
|
|
|
|
|
|
+ if (!options.hasOwnProperty(option) || !availableOptions.includes(option)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!availableOptions.includes(option)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- (<any>filteredOptions)[option] = (<any>options)[option];
|
|
|
|
|
|
+ filteredOptions[option] = options[option];
|
|
}
|
|
}
|
|
|
|
|
|
return filteredOptions;
|
|
return filteredOptions;
|
|
@@ -253,7 +250,7 @@ export class JavaScriptObfuscatorCLI {
|
|
|
|
|
|
private processData (): void {
|
|
private processData (): void {
|
|
const options: TInputOptions = this.buildOptions();
|
|
const options: TInputOptions = this.buildOptions();
|
|
- const outputCodePath: string = CLIUtils.getOutputCodePath((<any>this.commands).output, this.inputPath);
|
|
|
|
|
|
+ const outputCodePath: string = CLIUtils.getOutputCodePath(this.commands.output, this.inputPath);
|
|
|
|
|
|
if (options.sourceMap) {
|
|
if (options.sourceMap) {
|
|
this.processDataWithSourceMap(outputCodePath, options);
|
|
this.processDataWithSourceMap(outputCodePath, options);
|