diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-05-12 01:49:57 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-05-12 10:11:57 +0800 |
commit | 55d74f86440a5a804d4551e04f7fd39518af0723 (patch) | |
tree | a509c00c4bbf0b274030178493407ee723756185 /testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-raw-files-generator.js | |
parent | 6df5e1b763a1e8a022f6d3dad738c5b1df468a17 (diff) |
add web portal framework for TestAPI
Change-Id: I62cea8b59ffe6a6cde98051c130f4502c07d3557
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-raw-files-generator.js')
-rw-r--r-- | testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-raw-files-generator.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-raw-files-generator.js b/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-raw-files-generator.js new file mode 100644 index 0000000..ec8c531 --- /dev/null +++ b/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-raw-files-generator.js @@ -0,0 +1,46 @@ +/*! + * 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) + */ + +/* global btoa: true */ + +'use strict'; +var fs = require('fs'); +var btoa = require('btoa'); +var glob = require('glob'); + +function getFiles(type) { + var files = {}; + var recursive = (type === 'less'); + var globExpr = (recursive ? '/**/*' : '/*'); + glob.sync(type + globExpr) + .filter(function (path) { + return type === 'fonts' ? true : new RegExp('\\.' + type + '$').test(path); + }) + .forEach(function (fullPath) { + var relativePath = fullPath.replace(/^[^/]+\//, ''); + files[relativePath] = (type === 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8')); + }); + return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'; +} + +module.exports = function generateRawFilesJs(grunt, banner) { + if (!banner) { + banner = ''; + } + var dirs = ['js', 'less', 'fonts']; + var files = banner + dirs.map(getFiles).reduce(function (combined, file) { + return combined + file; + }, ''); + var rawFilesJs = 'docs/assets/js/raw-files.min.js'; + try { + fs.writeFileSync(rawFilesJs, files); + } + catch (err) { + grunt.fail.warn(err); + } + grunt.log.writeln('File ' + rawFilesJs.cyan + ' created.'); +}; |