mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
24 lines
628 B
JavaScript
24 lines
628 B
JavaScript
|
'use strict';
|
||
|
var fs = require('fs');
|
||
|
var path = require('path');
|
||
|
|
||
|
var destDir = 'dist/js';
|
||
|
var destFilename = 'npm.js';
|
||
|
var destFilepath = path.join(destDir, destFilename);
|
||
|
|
||
|
function srcPathToDestRequire(srcFilepath) {
|
||
|
var requirePath = path.relative(destDir, srcFilepath);
|
||
|
return "require('"+requirePath+"')";
|
||
|
}
|
||
|
|
||
|
module.exports = function generateCommonJSModule(grunt, files) {
|
||
|
var moduleOutputJs = files.map(srcPathToDestRequire).join('\n');
|
||
|
try {
|
||
|
fs.writeFileSync(destFilepath, moduleOutputJs);
|
||
|
}
|
||
|
catch (err) {
|
||
|
grunt.fail.warn(err);
|
||
|
}
|
||
|
grunt.log.writeln('File ' + destFilepath.cyan + ' created.');
|
||
|
};
|