mirror of
https://github.com/tabler/tabler-icons.git
synced 2025-01-17 12:48:26 +01:00
update icons script
This commit is contained in:
parent
4605a54a2e
commit
d6d0dd6c83
@ -3,11 +3,8 @@ import fs from 'fs'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { ICONS_SRC_DIR, getMaxUnicode, getArgvs, getPackageJson } from './helpers.mjs'
|
import { ICONS_SRC_DIR, getMaxUnicode, getArgvs, getPackageJson } from './helpers.mjs'
|
||||||
|
|
||||||
const p = getPackageJson(),
|
const argv = getArgvs(),
|
||||||
argv = getArgvs(),
|
newVersion = argv['new-version']
|
||||||
newVersion = argv['new-version'] || `${p.version}`
|
|
||||||
|
|
||||||
console.log(argv);
|
|
||||||
|
|
||||||
const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg'))
|
const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg'))
|
||||||
|
|
||||||
@ -34,11 +31,13 @@ files.forEach(function (file) {
|
|||||||
if (newVersion) {
|
if (newVersion) {
|
||||||
// Add version to svg files
|
// Add version to svg files
|
||||||
if (!svgFile.match(/\nversion: "?([a-f0-9.]+)"?/i)) {
|
if (!svgFile.match(/\nversion: "?([a-f0-9.]+)"?/i)) {
|
||||||
|
const minorVersion = newVersion.split('.').slice(0, 2).join('.')
|
||||||
|
|
||||||
svgFile = svgFile.replace(/-->\n<svg/i, function (m) {
|
svgFile = svgFile.replace(/-->\n<svg/i, function (m) {
|
||||||
return `version: "${newVersion}"\n${m}`
|
return `version: "${minorVersion}"\n${m}`
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(`Add version "${newVersion}" to "${file}"`)
|
console.log(`Add version "${minorVersion}" to "${file}"`)
|
||||||
fs.writeFileSync(file, svgFile, 'utf8')
|
fs.writeFileSync(file, svgFile, 'utf8')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user