ソースを参照

Added ability to specify the path to the input file after specifying the obfuscator options
Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/904

sanex 4 年 前
コミット
0926c13029

+ 4 - 0
CHANGELOG.md

@@ -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

ファイルの差分が大きいため隠しています
+ 0 - 0
dist/index.browser.js


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/index.cli.js


ファイルの差分が大きいため隠しています
+ 0 - 0
dist/index.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "javascript-obfuscator",
-  "version": "2.11.0",
+  "version": "2.11.1",
   "description": "JavaScript obfuscator",
   "keywords": [
     "obfuscator",

+ 1 - 1
src/cli/JavaScriptObfuscatorCLI.ts

@@ -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,

+ 50 - 20
test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts

@@ -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);
+                    it('should create file with obfuscated code in `--output` directory', () => {
+                        assert.equal(isFileExist, true);
+                    });
+
+                    after(() => {
+                        fs.unlinkSync(outputFilePath);
+                    });
                 });
 
-                after(() => {
-                    fs.unlinkSync(outputFilePath);
+                describe('Variant #2: input file path is after options', () => {
+                    let isFileExist: boolean;
+
+                    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);
+                    });
                 });
             });
 

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません