mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
24 lines
720 B
JavaScript
24 lines
720 B
JavaScript
'use strict';
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
var COMMONJS_BANNER = '// This file is generated. You can require() it in a CommonJS environment.\n';
|
|
|
|
module.exports = function generateCommonJSModule(grunt, srcFiles, destFilepath) {
|
|
var destDir = path.dirname(destFilepath);
|
|
|
|
function srcPathToDestRequire(srcFilepath) {
|
|
var requirePath = path.relative(destDir, srcFilepath);
|
|
return 'require(\'' + requirePath + '\')';
|
|
}
|
|
|
|
var moduleOutputJs = COMMONJS_BANNER + srcFiles.map(srcPathToDestRequire).join('\n');
|
|
try {
|
|
fs.writeFileSync(destFilepath, moduleOutputJs);
|
|
}
|
|
catch (err) {
|
|
grunt.fail.warn(err);
|
|
}
|
|
grunt.log.writeln('File ' + destFilepath.cyan + ' created.');
|
|
};
|