forked from michaelbazos/angular-feather
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.js
40 lines (29 loc) · 1.23 KB
/
docs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const del = require('del');
const fs = require('fs-extra');
const uppercamelcase = require('uppercamelcase');
const iconsSrcFolder = 'node_modules/feather-icons/dist/icons';
const iconListFile = 'LIST.md';
const version = require('./package.json').dependencies['feather-icons'];
// const rawgitUrl = `https://cdn.rawgit.com/feathericons/feather/v${version}/icons`;
const unpkgUrl = `https://unpkg.com/feather-icons@${version}/dist/icons`
return Promise.resolve()
// delete previous output
.then(() => del([iconListFile]))
// create destination folder
.then(() => {
fs.appendFileSync(iconListFile, `| | Symbol to import | HTML template |\n`);
fs.appendFileSync(iconListFile, `| --- | ---------------- | ------------------ |\n`);
fs.readdirSync(`${iconsSrcFolder}`).forEach(filename => {
'use strict';
const name = stripExtension(filename);
const svgUrl = `${unpkgUrl}/${filename}`;
fs.appendFileSync(
iconListFile,
`| ![${name}](${svgUrl}) | \`${uppercamelcase(name)}\` | \`<i-feather name="${name}"></i-feather>\` |\n`
);
});
})
.catch((err) => console.log(err));
function stripExtension(str) {
return str.substr(0, str.lastIndexOf('.'));
}