Browse Source

Fixed require of external user config file #2

sanex3339 7 years ago
parent
commit
58f606bcd8

+ 4 - 0
CHANGELOG.md

@@ -5,6 +5,10 @@ v0.11.0
 * **New option:** `log` enables logging of the information to the console.
 * **New option:** `renameGlobals` allows to enable obfuscation of global variable and function names with declaration.
 
+v0.10.1
+---
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/76
+
 v0.10.0
 ---
 * **New option:** `deadCodeInjection`. With this option random blocks of dead code will add to the obfuscated code.

File diff suppressed because it is too large
+ 0 - 0
dist/index.js


+ 8 - 4
src/cli/utils/CLIUtils.ts

@@ -78,11 +78,15 @@ export class CLIUtils {
      * @returns {Object}
      */
     public static getUserConfig (configPath: string): Object {
-        const nativeRequire: Function = typeof __non_webpack_require__ === 'function'
-            ? __non_webpack_require__
-            : require;
+        let config: Object;
 
-        return nativeRequire(configPath);
+        try {
+            config = require(configPath);
+        } catch (e) {
+            config = __non_webpack_require__(configPath);
+        }
+
+        return config;
     }
 
     /**

+ 0 - 0
test/functional-tests/javascript-obfuscator-cli/JavaScriptObfuscatorCLI.spec.ts → test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts


+ 1 - 1
test/index.spec.ts

@@ -30,7 +30,7 @@ import './unit-tests/utils/Utils.spec';
  * Functional tests
  */
 import './functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec';
-import './functional-tests/javascript-obfuscator-cli/JavaScriptObfuscatorCLI.spec';
+import './functional-tests/cli/JavaScriptObfuscatorCLI.spec';
 import './functional-tests/javascript-obfuscator-internal/JavaScriptObfuscatorInternal.spec';
 import './functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec';
 import './functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec';

Some files were not shown because too many files changed in this diff