mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
extract raw-files.js generator out of Gruntfile into separate module
This commit is contained in:
parent
b67fc6906a
commit
d1c29af591
2 changed files with 24 additions and 18 deletions
20
Gruntfile.js
20
Gruntfile.js
|
@ -11,7 +11,7 @@ module.exports = function (grunt) {
|
|||
}
|
||||
|
||||
var fs = require('fs')
|
||||
var btoa = require('btoa')
|
||||
var generateRawFilesJs = require('./docs/grunt/bs-raw-files-generator.js')
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
|
@ -360,21 +360,5 @@ module.exports = function (grunt) {
|
|||
});
|
||||
|
||||
// task for building customizer
|
||||
grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', function () {
|
||||
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)
|
||||
});
|
||||
grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', generateRawFilesJs);
|
||||
};
|
||||
|
|
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…
Reference in a new issue