File size: 529 Bytes
7e79d67 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | const join = require('path').join
const glob = require('glob')
const fs = require('fs')
const jsonPath = join(__dirname, '../src/background-images.json')
glob(join(__dirname, '../public/assets/images/background/*.jpg'), (err, paths) => {
if (err) throw err
let publicPaths = []
publicPaths = paths.map((path) => path.replace(/.*?public/, ''))
fs.writeFile(jsonPath, JSON.stringify(publicPaths), 'utf8', (err) => {
if (err) throw err
console.log(`Images JSON saved to: ${jsonPath}`)
process.exit(0)
})
})
|