Skip to content
This repository was archived by the owner on Oct 31, 2022. It is now read-only.

Commit 13d2806

Browse files
Test overwriting files
1 parent a19830d commit 13d2806

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

tasks/javascript_obfuscator.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
var JavaScriptObfuscator = require('javascript-obfuscator');
1212

1313
function concat(grunt, paths) {
14-
console.log("paths", paths);
15-
1614
if (paths.length === 0) {
1715
throw new Error('Source files not found.');
1816
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = require('./gruntfile_generic').setup({
2+
options: {},
3+
overwrite: {
4+
src: ['../../tmp/overwrite.js'],
5+
dest: '../../tmp/overwrite.js'
6+
}
7+
});

test/javascript_obfuscator_test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ exports.javascript_obfuscator = {
5757
test.ok(obfuscated.indexOf('FIRST_STRING_LITERAL') === -1, '`FIRST_STRING_LITERAL` should be obfuscated');
5858
test.ok(obfuscated.indexOf('SECOND_STRING_LITERAL') === -1, '`SECOND_STRING_LITERAL` should be obfuscated');
5959

60+
test.done();
61+
});
62+
},
63+
64+
overwrite: function(test) {
65+
test.expect(5);
66+
67+
grunt.file.copy('test/fixtures/first_sample.js', 'tmp/overwrite.js');
68+
69+
helper.callGruntfile('fixtures/gruntfile_overwrite.js', function (error, stdout, stderr) {
70+
test.equal(error, null, "Command should not fail.");
71+
test.equal(stderr, '', "Standard error stream should be empty.");
72+
73+
var obfuscated = grunt.file.read('tmp/overwrite.js');
74+
75+
// should NOT be obfuscated
76+
test.ok(obfuscated.indexOf('console') > -1, '`console` shouldn\'t be obfuscated');
77+
test.ok(obfuscated.indexOf('FIRST_LOCAL_VARIABLE') > -1, '`FIRST_LOCAL_VARIABLE` shouldn\'t be obfuscated');
78+
79+
// should be obfuscated
80+
test.ok(obfuscated.indexOf('FIRST_STRING_LITERAL') === -1, '`FIRST_STRING_LITERAL` should be obfuscated');
81+
6082
test.done();
6183
});
6284
}

0 commit comments

Comments
 (0)