mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Identifiers prefix generation for CLI directory obfuscation
This commit is contained in:
@@ -44,6 +44,11 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
*/
|
||||
public static obfuscatedFilePrefix: string = '-obfuscated';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
private static readonly baseIdentifiersPrefix: string = 'a';
|
||||
|
||||
/**
|
||||
* @type {string[]}
|
||||
*/
|
||||
@@ -353,8 +358,11 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
const outputCodePath: string = outputPath
|
||||
? path.join(outputPath, filePath)
|
||||
: CLIUtils.getOutputCodePath(filePath);
|
||||
const baseIdentifiersPrefix: string = this.inputCLIOptions.identifiersPrefix
|
||||
|| JavaScriptObfuscatorCLI.baseIdentifiersPrefix;
|
||||
const identifiersPrefix: string = `${baseIdentifiersPrefix}${index}`;
|
||||
|
||||
this.processSourceCode(content, outputCodePath);
|
||||
this.processSourceCode(content, outputCodePath, identifiersPrefix);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -362,9 +370,21 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
|
||||
/**
|
||||
* @param {string} sourceCode
|
||||
* @param {string} outputCodePath
|
||||
* @param {string | null} identifiersPrefix
|
||||
*/
|
||||
private processSourceCode (sourceCode: string, outputCodePath: string): void {
|
||||
const options: TInputOptions = this.buildOptions();
|
||||
private processSourceCode (
|
||||
sourceCode: string,
|
||||
outputCodePath: string,
|
||||
identifiersPrefix: string | null = null
|
||||
): void {
|
||||
let options: TInputOptions = this.buildOptions();
|
||||
|
||||
if (identifiersPrefix !== null) {
|
||||
options = {
|
||||
...options,
|
||||
identifiersPrefix
|
||||
};
|
||||
}
|
||||
|
||||
if (options.sourceMap) {
|
||||
JavaScriptObfuscatorCLI.processSourceCodeWithSourceMap(sourceCode, outputCodePath, options);
|
||||
|
||||
Reference in New Issue
Block a user