Make pre-compile.js and post-compile.js support underscore.js.

Former-commit-id: 76d040f630faf03bd5a8eb168259814f5662ba50
This commit is contained in:
John-David Dalton
2012-09-02 15:24:30 -07:00
parent 3a7661b111
commit 87d70f29a1
2 changed files with 23 additions and 7 deletions

View File

@@ -6,11 +6,15 @@
var fs = require('fs');
/** The minimal license/copyright template */
var licenseTemplate =
'/*!\n' +
' Lo-Dash @VERSION lodash.com/license\n' +
' Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE\n' +
'*/';
var licenseTemplate = {
'lodash':
'/*!\n' +
' Lo-Dash @VERSION lodash.com/license\n' +
' Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE\n' +
'*/',
'underscore':
'/*! Underscore.js @VERSION github.com/documentcloud/underscore/blob/master/LICENSE */'
};
/*--------------------------------------------------------------------------*/
@@ -29,7 +33,9 @@
}
// set the version
var license = licenseTemplate.replace('@VERSION', snippet[2]);
var license = (
snippet ? licenseTemplate[/lodash/i.test(source) ? 'lodash' : 'underscore'] : ''
).replace('@VERSION', snippet[2]);
// move vars exposed by Closure Compiler into the IIFE
source = source.replace(/^([^(\n]+)\s*(\(function[^)]+\){)/, '$2$1');