tweap copy script

pull/18/head
Evan You 5 years ago
parent 1394009242
commit d8f2eb1ffc

@ -1,30 +1,13 @@
// copy and watch non-ts files in src/client
const fs = require('fs-extra')
const path = require('path')
const globby = require('globby')
const chokidar = require('chokidar')
const pattern = 'src/client/**/!(*.ts|tsconfig.json)'
function toDest(file) {
return file.replace(/^src\//, 'dist/')
}
function copy(file) {
fs.copy(file, toDest(file))
}
// copy on start
;(async () => {
for (const file of await globby(pattern)) {
copy(file)
}
})()
chokidar
.watch(pattern)
.on('change', copy)
.on('add', copy)
.on('unlink', (file) => {
fs.remove(toDest(file))
})
.watch('src/client/**/!(*.ts|tsconfig.json)')
.on('change', (file) => fs.copy(file, toDest(file)))
.on('add', (file) => fs.copy(file, toDest(file)))
.on('unlink', (file) => fs.remove(toDest(file)))

Loading…
Cancel
Save