Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/icons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/add-svg-classes.js35
-rw-r--r--index.js30
-rw-r--r--package.json2
3 files changed, 36 insertions, 31 deletions
diff --git a/build/add-svg-classes.js b/build/add-svg-classes.js
new file mode 100644
index 000000000..ca0080749
--- /dev/null
+++ b/build/add-svg-classes.js
@@ -0,0 +1,35 @@
+'use strict'
+
+const fs = require('fs')
+const path = require('path')
+
+const iconsDir = path.join(__dirname, '../icons/')
+
+//
+// Add classnames
+//
+
+fs.readdir(iconsDir, (error, files) => {
+ if (error) {
+ throw error
+ }
+
+ files.forEach((file, index) => {
+ file = path.join(iconsDir, file)
+
+ fs.readFile(file, 'utf8', (err, data) => {
+ if (err) {
+ throw err
+ }
+
+ const result = data.replace('<svg', `<svg class="bi bi-${path.basename(file, '.svg')}"`)
+ console.log(`${index}. ${path.basename(file, '.svg')}`)
+
+ fs.writeFile(file, result, 'utf8', err => {
+ if (err) {
+ throw err
+ }
+ })
+ })
+ })
+})
diff --git a/index.js b/index.js
deleted file mode 100644
index c23bd12b9..000000000
--- a/index.js
+++ /dev/null
@@ -1,30 +0,0 @@
-var fs = require('fs');
-var path = require('path');
-var iconsDir = "./icons/";
-
-//
-// Add classnames
-//
-
-fs.readdir(iconsDir, function (error, files) {
- if (error) {
- console.error("Could not read icons directory.", error);
- process.exit(1);
- }
-
- files.forEach(function (file, index) {
- var file = __dirname + '/icons/' + file;
-
- fs.readFile(file, 'utf8', function (err, data) {
- if (err) {
- return console.log(err);
- }
- var result = data.replace('<svg', '<svg class="bi bi-' + path.basename(file, '.svg') + '"');
- console.log(index + '. ' + path.basename(file, '.svg'));
-
- fs.writeFile(file, result, 'utf8', function (err) {
- if (err) return console.log(err);
- });
- });
- });
-});
diff --git a/package.json b/package.json
index 5bedf1cf9..3f5d34a8f 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"docs-serve": "hugo server --port 4000 --disableFastRender",
"docs-build": "hugo --cleanDestinationDir",
"icons-prep": "svgo --config=svgo.yml --input=icons/",
- "icons-classes": "node index.js",
+ "icons-classes": "node build/add-svg-classes.js",
"icons-zip": "cross-env-shell \"shx rm -rf bootstrap-icons-$npm_package_version && shx cp -r icons/ bootstrap-icons-$npm_package_version && zip -r9 bootstrap-icons-$npm_package_version.zip bootstrap-icons-$npm_package_version && shx rm -rf bootstrap-icons-$npm_package_version\"",
"push-pages": "cd _site && git init && git remote add staging https://github.com/twbs/icons/ && git add . && git commit -m \"Publishing latest changes\" && git push staging master:gh-pages --force && git remote rm staging",
"publish": "cross-env HUGO_ENV=production npm run docs-build && npm run push-pages"