src/generate.js
async function buildPathsObject(files) {
  return Promise.all(
    files.map(async filepath => {
      const name = path.basename(filepath, '.svg');
      const svg = fs.readFileSync(filepath, 'utf-8');
      const pathStrings = await svgo.optimize(svg, { path: filepath })
        .then(({ data }) => data.match(/ d="[^"]+"/g) || [])
        .then(paths => paths.map(s => s.slice(3)));
      return `"${name}": [${pathStrings.join(',\n')}]`;
    }),
  );
}
async function buildPathsObject(files) {
  return Promise.all(
    files.map(async filepath => {
      const name = path.basename(filepath, '.svg');
      const svg = fs.readFileSync(filepath, 'utf-8');
      const pathStrings = await svgo.optimize(svg, { path: filepath })
        .then(({ data }) => data.match(/ d="[^"]+"/g) || [])
        .then(paths => paths.map(s => s.slice(3)));
      return `"${name}": [${pathStrings.join(',\n')}]`;
    }),
  );
}
async function buildPathsObject ( files ) { return Promise . all ( files . map ( async filepath => { const name = path . basename ( filepath , '.svg' ) ; const svg = fs . readFileSync ( filepath , 'utf-8' ) ; const pathStrings = await svgo . optimize ( svg , { path : filepath } ) . then ( ( { data } ) => data . match ( /  d="[^"]+" / g ) || [ ] ) . then ( paths => paths . map ( s => s . slice ( 3 ) ) ) ; return ` ${ name } ${ pathStrings . join ( ',\n' ) } ` ; } ) , ) ; }
Loads SVG file for each icon, extracts path strings `d="path-string"`,
and constructs map of icon name to array of path strings.
@param {array} files
Loads SVG file for each icon extracts path strings d = path - string and constructs map of icon name to array of path strings .