Skip to content

Commit 015ee2e

Browse files
committed
pulled output path out to gruntfile
1 parent 9aeaf19 commit 015ee2e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Gruntfile.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ module.exports = function (grunt) {
438438
grunt.registerTask('test', testSubtasks);
439439

440440
// JS distribution task.
441-
grunt.registerTask('dist-js', ['concat', 'uglify:core']);
441+
grunt.registerTask('dist-js', ['concat', 'uglify:core', 'commonjs']);
442442

443443
// CSS distribution task.
444444
grunt.registerTask('less-compile', ['less:compileCore', 'less:compileTheme']);
@@ -464,8 +464,9 @@ module.exports = function (grunt) {
464464
});
465465

466466
grunt.registerTask('commonjs', 'Generate CommonJS entrypoint module in dist dir.', function () {
467-
var files = grunt.config.get('concat.bootstrap.src');
468-
generateCommonJSModule(grunt, files);
467+
var srcFiles = grunt.config.get('concat.bootstrap.src');
468+
var destFilepath = 'dist/js/npm.js';
469+
generateCommonJSModule(grunt, srcFiles, destFilepath);
469470
});
470471

471472
// Docs task.

grunt/bs-commonjs-generator.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
var fs = require('fs');
33
var path = require('path');
44

5-
var destDir = 'dist/js';
6-
var destFilename = 'npm.js';
7-
var destFilepath = path.join(destDir, destFilename);
5+
module.exports = function generateCommonJSModule(grunt, srcFiles, destFilepath) {
6+
var destDir = path.dirname(destFilepath);
87

9-
function srcPathToDestRequire(srcFilepath) {
10-
var requirePath = path.relative(destDir, srcFilepath);
11-
return "require('"+requirePath+"')";
12-
}
8+
function srcPathToDestRequire(srcFilepath) {
9+
var requirePath = path.relative(destDir, srcFilepath);
10+
return "require('"+requirePath+"')";
11+
}
1312

14-
module.exports = function generateCommonJSModule(grunt, files) {
15-
var moduleOutputJs = files.map(srcPathToDestRequire).join('\n');
13+
var moduleOutputJs = srcFiles.map(srcPathToDestRequire).join('\n');
14+
1615
try {
1716
fs.writeFileSync(destFilepath, moduleOutputJs);
1817
}

0 commit comments

Comments
 (0)