2014-01-08 07:15:48 +01:00
|
|
|
/* jshint node: true */
|
2014-01-21 01:00:52 +01:00
|
|
|
/*!
|
|
|
|
* Bootstrap Grunt task for generating raw-files.min.js for the Customizer
|
|
|
|
* http://getbootstrap.com
|
|
|
|
* Copyright 2014 Twitter, Inc.
|
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
|
|
*/
|
2014-01-08 07:15:48 +01:00
|
|
|
|
2014-01-09 03:45:40 +01:00
|
|
|
var btoa = require('btoa') // jshint ignore:line
|
2014-01-08 07:15:48 +01:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2014-01-14 22:25:27 +01:00
|
|
|
module.exports = function generateRawFilesJs(banner) {
|
|
|
|
if (!banner) {
|
|
|
|
banner = ''
|
|
|
|
}
|
|
|
|
var files = banner + getFiles('js') + getFiles('less') + getFiles('fonts')
|
2014-01-20 07:28:25 +01:00
|
|
|
fs.writeFileSync('docs/assets/js/raw-files.min.js', files)
|
2014-01-08 07:15:48 +01:00
|
|
|
}
|