Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function bundleJs() {
// start the build process for index.js (for ES6/7 support in CEF)
require('browserify')(jsEntry, {
debug: false,
plugin: [
[require('prependify'), 'nodeRequire = require;']
]
})
.bundle(function (err, bundle) {
if (err) {
console.error(err.stack)
return
}
fs.writeFileSync(jsBundle, bundle)
const result = uglifyJS.minify([jsBundle])
fs.writeFileSync(jsBundle, result.code)
})
}
exports.precedence = function () {
var src = browserify.bundle({
base : __dirname + '/modules/precedence',
require : [ 'hashish', 'traverse' ],
});
var c = { console : console };
vm.runInNewContext(src, c);
assert.ok(c.require.modules['hashish/package.json']);
assert.deepEqual(
c.require.modules['hashish/index.js']().map(
{ a : 1, b :2 }, function (x) { return x * 100 }
),
{ a : 100, b : 200 }
);
assert.ok(c.require.modules['./node_modules/hashish/index.js']);
assert.notEqual(
c.require.modules['hashish/index.js'](),
exports.walk = function () {
var src = browserify.bundle(__dirname + '/walk');
var context = {};
vm.runInNewContext(src, context);
var a_ = context.require('a');
var b_ = context.require('b');
var c_ = context.require('c');
assert.throws(function () {
context.require('d');
});
assert.throws(function () {
context.require('e');
});
exports.single_file = function () {
var src = browserify.bundle({
require : 'jade/lib/lexer.js'
});
assert.ok(typeof src === 'string');
assert.ok(src.length > 0);
var c = {};
vm.runInNewContext(src, c);
var lex = vm.runInNewContext(
'var Lexer = require("jade/lib/lexer"); Lexer', c
);
assert.eql(
Object.keys(Lexer),
Object.keys(lex)
);
};
exports.modules = function () {
var src = browserify.bundle({
base : {
'foomoduletest' : __dirname + '/modules/foomoduletest'
},
});
assert.ok(typeof src === 'string');
assert.ok(src.length > 0);
var c = {};
vm.runInNewContext(src, c);
assert.eql(c.require('foomoduletest').bar, 55)
};
exports.named = function () {
var src = browserify.bundle({
base : { names : __dirname + '/names' }
});
var c = {};
vm.runInNewContext(src, c);
assert.eql(c.require('names').names, {
__dirname : 'names',
__filename : 'names/index.js',
});
};
exports.stringBase = function () {
var src = browserify.bundle(__dirname + '/base/string');
var c = { console : console };
vm.runInNewContext(src, c);
assert.equal(c.require('./')(3), 13000);
};
exports.objectRequire = function () {
var src = browserify.bundle({
require : { 'doom' : 'hashish' },
});
var c = {};
vm.runInNewContext(src, c);
verifyHashish(c.require('doom'))
assert.ok(c.require.modules['doom/package.json']);
assert.ok(!c.require.modules['hashish/package.json']);
};