mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-20 17:54:23 +01:00
extract raw-files.js generator out of Gruntfile into separate module
This commit is contained in:
parent
b67fc6906a
commit
d1c29af591
20
Gruntfile.js
20
Gruntfile.js
@ -11,7 +11,7 @@ module.exports = function (grunt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
var btoa = require('btoa')
|
var generateRawFilesJs = require('./docs/grunt/bs-raw-files-generator.js')
|
||||||
|
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
@ -360,21 +360,5 @@ module.exports = function (grunt) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// task for building customizer
|
// task for building customizer
|
||||||
grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', function () {
|
grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', generateRawFilesJs);
|
||||||
function getFiles(type) {
|
|
||||||
var files = {}
|
|
||||||
fs.readdirSync(type)
|
|
||||||
.filter(function (path) {
|
|
||||||
return type == 'fonts' ? true : new RegExp('\\.' + type + '$').test(path)
|
|
||||||
})
|
|
||||||
.forEach(function (path) {
|
|
||||||
var fullPath = type + '/' + path
|
|
||||||
return files[path] = (type == 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'))
|
|
||||||
})
|
|
||||||
return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'
|
|
||||||
}
|
|
||||||
|
|
||||||
var files = getFiles('js') + getFiles('less') + getFiles('fonts')
|
|
||||||
fs.writeFileSync('docs/assets/js/raw-files.js', files)
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
22
docs/grunt/bs-raw-files-generator.js
Normal file
22
docs/grunt/bs-raw-files-generator.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* jshint node: true */
|
||||||
|
|
||||||
|
var btoa = require('btoa')
|
||||||
|
var fs = require('fs')
|
||||||
|
|
||||||
|
function getFiles(type) {
|
||||||
|
var files = {}
|
||||||
|
fs.readdirSync(type)
|
||||||
|
.filter(function (path) {
|
||||||
|
return type == 'fonts' ? true : new RegExp('\\.' + type + '$').test(path)
|
||||||
|
})
|
||||||
|
.forEach(function (path) {
|
||||||
|
var fullPath = type + '/' + path
|
||||||
|
return files[path] = (type == 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'))
|
||||||
|
})
|
||||||
|
return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function generateRawFilesJs() {
|
||||||
|
var files = getFiles('js') + getFiles('less') + getFiles('fonts')
|
||||||
|
fs.writeFileSync('docs/assets/js/raw-files.js', files)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user