source: trip-planner-front/node_modules/bootstrap/grunt/bs-raw-files-generator.js@ fa375fe

Last change on this file since fa375fe was fa375fe, checked in by Ema <ema_spirova@…>, 3 years ago

adding new components

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*!
2 * Bootstrap Grunt task for generating raw-files.min.js for the Customizer
3 * https://getbootstrap.com/
4 * Copyright 2014-2019 Twitter, Inc.
5 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6 */
7
8'use strict';
9
10var fs = require('fs');
11var btoa = require('btoa');
12var glob = require('glob');
13
14function getFiles(type) {
15 var files = {};
16 var recursive = type === 'less';
17 var globExpr = recursive ? '/**/*' : '/*';
18 glob.sync(type + globExpr)
19 .filter(function (path) {
20 return type === 'fonts' ? true : new RegExp('\\.' + type + '$').test(path);
21 })
22 .forEach(function (fullPath) {
23 var relativePath = fullPath.replace(/^[^/]+\//, '');
24 files[relativePath] = type === 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8');
25 });
26 return 'var __' + type + ' = ' + JSON.stringify(files) + '\n';
27}
28
29module.exports = function generateRawFilesJs(grunt, banner) {
30 if (!banner) {
31 banner = '';
32 }
33 var dirs = ['js', 'less', 'fonts'];
34 var files = banner + dirs.map(getFiles).reduce(function (combined, file) {
35 return combined + file;
36 }, '');
37 var rawFilesJs = 'docs/assets/js/raw-files.min.js';
38 try {
39 fs.writeFileSync(rawFilesJs, files);
40 } catch (err) {
41 grunt.fail.warn(err);
42 }
43 grunt.log.writeln('File ' + rawFilesJs.cyan + ' created.');
44};
Note: See TracBrowser for help on using the repository browser.