1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-13 00:54:04 +02:00

extract raw-files.js generator out of Gruntfile into separate module

This commit is contained in:
Chris Rebert
2014-01-07 22:15:48 -08:00
parent b67fc6906a
commit d1c29af591
2 changed files with 24 additions and 18 deletions

View 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)
}