Merge pull request #905 from javascript-obfuscator/cli-argument-order

Added ability to specify the path to the input file after specifying the obfuscator options
This commit is contained in:
Timofey Kachalov
2021-04-07 20:21:21 +03:00
committed by GitHub
7 changed files with 59 additions and 25 deletions
+4
View File
@@ -1,5 +1,9 @@
Change Log
v2.11.1
---
* **CLI**: now it's possible to specify the path to the input file after specifying the obfuscator options. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/904
v2.11.0
---
* Added option `renamePropertiesMode` to switch between new `safe` and old `unsafe` modes of `renameProperties` option. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/878
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "2.11.0",
"version": "2.11.1",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
+1 -1
View File
@@ -137,12 +137,12 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
}
public initialize (): void {
this.inputPath = path.normalize(this.arguments[0] || '');
this.commands = <commander.CommanderStatic>(new commander.Command());
this.configureCommands();
this.configureHelp();
this.inputPath = path.normalize(this.commands.args[0] || '');
this.inputCLIOptions = JavaScriptObfuscatorCLI.buildOptions(this.commands.opts());
this.sourceCodeReader = new SourceCodeReader(
this.inputPath,
@@ -32,31 +32,61 @@ describe('JavaScriptObfuscatorCLI', function (): void {
});
describe('Variant #1: obfuscation of single file', () => {
describe('`--output` option is set', () => {
let isFileExist: boolean;
describe('--output` option is set', () => {
describe('Variant #1: input file path is before options', () => {
let isFileExist: boolean;
before(() => {
JavaScriptObfuscatorCLI.obfuscate([
'node',
'javascript-obfuscator',
fixtureFilePath,
'--output',
outputFilePath,
'--compact',
'true',
'--self-defending',
'0'
]);
before(() => {
JavaScriptObfuscatorCLI.obfuscate([
'node',
'javascript-obfuscator',
fixtureFilePath,
'--output',
outputFilePath,
'--compact',
'true',
'--self-defending',
'0'
]);
isFileExist = fs.existsSync(outputFilePath);
isFileExist = fs.existsSync(outputFilePath);
});
it('should create file with obfuscated code in `--output` directory', () => {
assert.equal(isFileExist, true);
});
after(() => {
fs.unlinkSync(outputFilePath);
});
});
it('should create file with obfuscated code in `--output` directory', () => {
assert.equal(isFileExist, true);
});
describe('Variant #2: input file path is after options', () => {
let isFileExist: boolean;
after(() => {
fs.unlinkSync(outputFilePath);
before(() => {
JavaScriptObfuscatorCLI.obfuscate([
'node',
'javascript-obfuscator',
'--output',
outputFilePath,
'--compact',
'true',
'--self-defending',
'0',
fixtureFilePath
]);
isFileExist = fs.existsSync(outputFilePath);
});
it('should create file with obfuscated code in `--output` directory', () => {
assert.equal(isFileExist, true);
});
after(() => {
fs.unlinkSync(outputFilePath);
});
});
});