Skip to content

Commit 99194f1

Browse files
authored
Merge pull request javascript-obfuscator#905 from javascript-obfuscator/cli-argument-order
Added ability to specify the path to the input file after specifying the obfuscator options
2 parents 2d120ab + 0926c13 commit 99194f1

File tree

7 files changed

+59
-25
lines changed

7 files changed

+59
-25
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Change Log
22

3+
v2.11.1
4+
---
5+
* **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
6+
37
v2.11.0
48
---
59
* 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

dist/index.browser.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.cli.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javascript-obfuscator",
3-
"version": "2.11.0",
3+
"version": "2.11.1",
44
"description": "JavaScript obfuscator",
55
"keywords": [
66
"obfuscator",

src/cli/JavaScriptObfuscatorCLI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
137137
}
138138

139139
public initialize (): void {
140-
this.inputPath = path.normalize(this.arguments[0] || '');
141140
this.commands = <commander.CommanderStatic>(new commander.Command());
142141

143142
this.configureCommands();
144143
this.configureHelp();
145144

145+
this.inputPath = path.normalize(this.commands.args[0] || '');
146146
this.inputCLIOptions = JavaScriptObfuscatorCLI.buildOptions(this.commands.opts());
147147
this.sourceCodeReader = new SourceCodeReader(
148148
this.inputPath,

test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,61 @@ describe('JavaScriptObfuscatorCLI', function (): void {
3232
});
3333

3434
describe('Variant #1: obfuscation of single file', () => {
35-
describe('`--output` option is set', () => {
36-
let isFileExist: boolean;
35+
describe('--output` option is set', () => {
36+
describe('Variant #1: input file path is before options', () => {
37+
let isFileExist: boolean;
3738

38-
before(() => {
39-
JavaScriptObfuscatorCLI.obfuscate([
40-
'node',
41-
'javascript-obfuscator',
42-
fixtureFilePath,
43-
'--output',
44-
outputFilePath,
45-
'--compact',
46-
'true',
47-
'--self-defending',
48-
'0'
49-
]);
39+
before(() => {
40+
JavaScriptObfuscatorCLI.obfuscate([
41+
'node',
42+
'javascript-obfuscator',
43+
fixtureFilePath,
44+
'--output',
45+
outputFilePath,
46+
'--compact',
47+
'true',
48+
'--self-defending',
49+
'0'
50+
]);
5051

51-
isFileExist = fs.existsSync(outputFilePath);
52-
});
52+
isFileExist = fs.existsSync(outputFilePath);
53+
});
5354

54-
it('should create file with obfuscated code in `--output` directory', () => {
55-
assert.equal(isFileExist, true);
55+
it('should create file with obfuscated code in `--output` directory', () => {
56+
assert.equal(isFileExist, true);
57+
});
58+
59+
after(() => {
60+
fs.unlinkSync(outputFilePath);
61+
});
5662
});
5763

58-
after(() => {
59-
fs.unlinkSync(outputFilePath);
64+
describe('Variant #2: input file path is after options', () => {
65+
let isFileExist: boolean;
66+
67+
before(() => {
68+
JavaScriptObfuscatorCLI.obfuscate([
69+
'node',
70+
'javascript-obfuscator',
71+
'--output',
72+
outputFilePath,
73+
'--compact',
74+
'true',
75+
'--self-defending',
76+
'0',
77+
fixtureFilePath
78+
]);
79+
80+
isFileExist = fs.existsSync(outputFilePath);
81+
});
82+
83+
it('should create file with obfuscated code in `--output` directory', () => {
84+
assert.equal(isFileExist, true);
85+
});
86+
87+
after(() => {
88+
fs.unlinkSync(outputFilePath);
89+
});
6090
});
6191
});
6292

0 commit comments

Comments
 (0)