refactor: reuse sync

pull/2428/head
zonemeen 3 years ago
parent 0d0c1caf80
commit aaa9963787

@ -5,10 +5,9 @@ function toDest(file) {
return file.replace(/^src\//, 'dist/')
}
const copyPromises = []
fg.stream('src/client/**').on('data', (file) => {
if (/(\.ts|tsconfig\.json)$/.test(file)) return
copyPromises.push(copy(file, toDest(file)))
})
await Promise.all(copyPromises)
await Promise.all(
fg.sync('src/client/**').map((file) => {
if (/(\.ts|tsconfig\.json)$/.test(file)) return
return copy(file, toDest(file))
})
)

@ -1,12 +1,12 @@
import { copy } from 'fs-extra'
import fg from 'fast-glob'
const copyPromises = []
fg.stream('src/shared/**/*.ts').on('data', (file) => {
copyPromises.push(
copy(file, file.replace(/^src\/shared\//, 'src/node/')),
copy(file, file.replace(/^src\/shared\//, 'src/client/'))
)
})
await Promise.all(copyPromises)
await Promise.all(
fg
.sync('src/shared/**/*.ts')
.map((file) => [
copy(file, file.replace(/^src\/shared\//, 'src/node/')),
copy(file, file.replace(/^src\/shared\//, 'src/client/'))
])
.flat()
)

Loading…
Cancel
Save