1
0

index.js 822 B

123456789101112131415161718192021222324252627
  1. const importIcons = require('./files')
  2. const config = require('./figma-import.config')
  3. const configTest = () => {
  4. const missingFields = []
  5. if (!config.hasOwnProperty('FIGMA_TOKEN')) missingFields.push('figmaToken')
  6. if (!config.hasOwnProperty('FILE_KEY')) missingFields.push('FILE_KEY')
  7. if (!config.hasOwnProperty('FRAME_WITH_ICONS_ID')) missingFields.push('FRAME_WITH_ICONS_ID')
  8. if (!config.hasOwnProperty('FRAME_WITH_ILLUSTRATIONS_ID')) missingFields.push('FRAME_WITH_ILLUSTRATIONS_ID')
  9. if (missingFields.length) {
  10. throw new Error(
  11. `The following fields are missing in the configuration file:${missingFields.map((item) => ` ${item}`)}`
  12. )
  13. }
  14. }
  15. const main = async () => {
  16. await importIcons()
  17. }
  18. try {
  19. configTest()
  20. main()
  21. } catch (error) {
  22. console.error('Unhandled rejection', error)
  23. }