mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
added back babel-polyfill
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"presets": ["es2015"],
|
||||
"plugins": [
|
||||
"transform-array-from",
|
||||
"transform-object-assign"
|
||||
]
|
||||
}
|
||||
@@ -2,4 +2,8 @@
|
||||
|
||||
import { JavaScriptObfuscator } from './src/JavaScriptObfuscator';
|
||||
|
||||
if (!(<any>global)._babelPolyfill) {
|
||||
require('babel-polyfill');
|
||||
}
|
||||
|
||||
module.exports = JavaScriptObfuscator;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.9.0",
|
||||
"babel-loader": "^6.2.4",
|
||||
"babel-plugin-transform-array-from": "^1.0.0",
|
||||
"babel-plugin-transform-object-assign": "^6.8.0",
|
||||
"babel-preset-es2015": "^6.9.0",
|
||||
"chai": "^3.5.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
$(npm bin)/tsc -p tsconfig-test.json
|
||||
$(npm bin)/babel test-tmp --out-dir test-tmp --source-maps --presets es2015 --plugins transform-array-from,transform-object-assign
|
||||
$(npm bin)/babel test-tmp --out-dir test-tmp --source-maps --presets es2015 --plugins transform-object-assign
|
||||
@@ -12,10 +12,6 @@ import { JavaScriptObfuscatorCLI } from "./cli/JavaScriptObfuscatorCLI";
|
||||
import { Obfuscator } from "./Obfuscator";
|
||||
import { Options } from "./Options";
|
||||
|
||||
if (!(<any>global)._babelPolyfill) {
|
||||
require('babel-polyfill');
|
||||
}
|
||||
|
||||
export class JavaScriptObfuscator {
|
||||
/**
|
||||
* @type {GenerateOptions}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { JavaScriptObfuscator } from "../src/JavaScriptObfuscator";
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from "../src/preset-options/NoCustomNodesPreset";
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('JavaScriptObfuscator', () => {
|
||||
describe('obfuscate (sourceCode: string, customOptions?: IOptionsPreset): string', () => {
|
||||
it('should obfuscate simple code with variable inside global scope', () => {
|
||||
|
||||
@@ -2,12 +2,16 @@ import * as fs from 'fs';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { StdoutWriteMock } from "../test/mocks/StdoutWriteMock";
|
||||
|
||||
import { JavaScriptObfuscator } from "../src/JavaScriptObfuscator";
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let fixturesDirName: string = 'test/fixtures',
|
||||
fixtureFileName: string = 'sample.js',
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { IBlockStatementNode } from "../src/interfaces/nodes/IBlockStatementNode";
|
||||
import { IFunctionDeclarationNode } from "../src/interfaces/nodes/IFunctionDeclarationNode";
|
||||
import { IIdentifierNode } from "../src/interfaces/nodes/IIdentifierNode";
|
||||
@@ -12,6 +14,8 @@ import { NodeUtils } from '../src/NodeUtils';
|
||||
|
||||
const assert: any = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
function getProgramNode (bodyNodes: INode[] = []): IProgramNode {
|
||||
return {
|
||||
type: NodeType.Program,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { IOptionsPreset } from "../src/interfaces/IOptionsPreset";
|
||||
|
||||
import { OptionsNormalizer } from '../src/OptionsNormalizer';
|
||||
@@ -6,6 +8,8 @@ import { DEFAULT_PRESET } from '../src/preset-options/DefaultPreset';
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('OptionsNormalizer', () => {
|
||||
describe('normalizeOptionsPreset (options: IOptionsPreset): IOptionsPreset', () => {
|
||||
let optionsPreset1: IOptionsPreset = Object.assign({}, DEFAULT_PRESET, {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { Utils } from '../src/Utils';
|
||||
|
||||
import { JSFuck } from '../src/enums/JSFuck';
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('Utils', () => {
|
||||
describe('arrayContains (array: any[], searchElement: any): boolean', () => {
|
||||
it('should return boolean depends on condition if array is contains given value or not', () => {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export class BabelPolyfill {
|
||||
public static append (): void {
|
||||
if (!(<any>global)._babelPolyfill) {
|
||||
require('babel-polyfill');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user