update-readme.mjs 1.1 KB

1234567891011121314151617181920212223242526
  1. import { readFileSync, writeFileSync } from 'fs'
  2. import { glob } from 'glob'
  3. import { resolve } from 'path'
  4. import { HOME_DIR, ICONS_SRC_DIR } from './helpers.mjs'
  5. let count = glob.sync(resolve(ICONS_SRC_DIR, '**/*.svg')).length,
  6. outlineCount = glob.sync(resolve(ICONS_SRC_DIR, '**/outline/*.svg')).length,
  7. filledCount = glob.sync(resolve(ICONS_SRC_DIR, '**/filled/*.svg')).length
  8. console.log('count', count);
  9. console.log('filledCount', filledCount);
  10. console.log('outlineCount', outlineCount);
  11. const readmes = glob.sync(resolve(HOME_DIR, '{.,packages/*}/README.md'))
  12. readmes.forEach(readme => {
  13. let fileData = readFileSync(readme).toString()
  14. fileData = fileData.replace(/<!--icons-count-->(.*?)<!--\/icons-count-->/, `<!--icons-count-->${count}<!--/icons-count-->`)
  15. .replace(/<!--icons-count-outline-->(.*?)<!--\/icons-count-outline-->/, `<!--icons-count-outline-->${outlineCount}<!--/icons-count-outline-->`)
  16. .replace(/<!--icons-count-filled-->(.*?)<!--\/icons-count-filled-->/, `<!--icons-count-filled-->${filledCount}<!--/icons-count-filled-->`)
  17. writeFileSync(readme, fileData)
  18. })