Add "iife=.." command to build.js.

Former-commit-id: 85d8c7ea550403663a878f2713ce93ae8c2dbc6a
This commit is contained in:
John-David Dalton
2012-09-10 22:52:28 -07:00
parent cbe46afdff
commit b406246689
2 changed files with 61 additions and 7 deletions

View File

@@ -585,7 +585,8 @@
'exports=amd',
'exports=commonjs',
'exports=global',
'exports=node'
'exports=node',
'exports=none'
];
commands.forEach(function(command, index) {
@@ -626,6 +627,11 @@
vm.runInContext(source, context);
ok(context._ === undefined, basename);
ok(_.isFunction(context.module.exports), basename);
break;
case 4:
vm.runInContext(source, context);
ok(context._ === undefined, basename);
}
start();
});
@@ -635,6 +641,30 @@
/*--------------------------------------------------------------------------*/
QUnit.module('iife command');
(function() {
var start = _.after(2, _.once(QUnit.start));
asyncTest('`lodash iife=...`', function() {
build(['-s', 'iife=!function(window,undefined){%output%}(this)'], function(source, filepath) {
var basename = path.basename(filepath, '.js'),
context = createContext();
try {
vm.runInContext(source, context);
} catch(e) { }
var lodash = context._ || {};
ok(_.isString(lodash.VERSION), basename);
ok(/!function/.test(source), basename);
start();
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('output options');
(function() {
@@ -676,7 +706,7 @@
(function() {
var start = _.once(QUnit.start);
asyncTest('`minify underscore.js`', function() {
asyncTest('`node minify underscore.js`', function() {
var source = fs.readFileSync(path.join(__dirname, '..', 'vendor', 'underscore', 'underscore.js'), 'utf8');
minify(source, {
'silent': true,