summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2017-05-12 06:26:03 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-05-12 06:26:03 +0000
commit5c9ea3e40e3a5dd25024ac1851caff800d93ae94 (patch)
treedd555075d89cb66ad4ccf961eecc77352a6b03a4 /utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js
parent302090eef8ae1ffbaf0d702821980b636f8464ff (diff)
parentf562c31e824f573d9a3254a1eacb4981b29290eb (diff)
Merge "add web portal framework for TestAPI"
Diffstat (limited to 'utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js')
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js b/utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js
new file mode 100644
index 000000000..339fd0ffe
--- /dev/null
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js
@@ -0,0 +1,41 @@
+/*!
+ * Bootstrap Grunt task for Glyphicons data generation
+ * http://getbootstrap.com
+ * Copyright 2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ */
+'use strict';
+var fs = require('fs');
+
+module.exports = function generateGlyphiconsData(grunt) {
+ // Pass encoding, utf8, so `readFileSync` will return a string instead of a
+ // buffer
+ var glyphiconsFile = fs.readFileSync('less/glyphicons.less', 'utf8');
+ var glyphiconsLines = glyphiconsFile.split('\n');
+
+ // Use any line that starts with ".glyphicon-" and capture the class name
+ var iconClassName = /^\.(glyphicon-[a-zA-Z0-9-]+)/;
+ var glyphiconsData = '# This file is generated via Grunt task. **Do not edit directly.**\n' +
+ '# See the \'build-glyphicons-data\' task in Gruntfile.js.\n\n';
+ var glyphiconsYml = 'docs/_data/glyphicons.yml';
+ for (var i = 0, len = glyphiconsLines.length; i < len; i++) {
+ var match = glyphiconsLines[i].match(iconClassName);
+
+ if (match !== null) {
+ glyphiconsData += '- ' + match[1] + '\n';
+ }
+ }
+
+ // Create the `_data` directory if it doesn't already exist
+ if (!fs.existsSync('docs/_data')) {
+ fs.mkdirSync('docs/_data');
+ }
+
+ try {
+ fs.writeFileSync(glyphiconsYml, glyphiconsData);
+ }
+ catch (err) {
+ grunt.fail.warn(err);
+ }
+ grunt.log.writeln('File ' + glyphiconsYml.cyan + ' created.');
+};