aboutsummaryrefslogtreecommitdiff
path: root/build/helpers.js
blob: b064a87e92831e4d75c152ff8ee290b6ae6c7621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const path = require('path');

const camelize = function (str) {
  str = str.replace(/-/g, ' ')

  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
    return word.toUpperCase()
  }).replace(/\s+/g, '')
}

exports.componentName = function (file) {
  file = path.basename(file, '.svg')
  file = camelize(`Icon ${file}`)

  return file
}

exports.optimizeSvgCode = function (svgCode) {
  return svgCode.replace(/<path stroke="none" d="M0 0h24v24H0z"[^>]+>/, '')
}