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 // copy and watch non-ts files in src/client
const fs = require('fs-extra') const fs = require('fs-extra')
const path = require('path')
const globby = require('globby')
const chokidar = require('chokidar') const chokidar = require('chokidar')
const pattern = 'src/client/**/!(*.ts|tsconfig.json)'
function toDest(file) { function toDest(file) {
return file.replace(/^src\//, 'dist/') 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 chokidar
.watch(pattern) .watch('src/client/**/!(*.ts|tsconfig.json)')
.on('change', copy) .on('change', (file) => fs.copy(file, toDest(file)))
.on('add', copy) .on('add', (file) => fs.copy(file, toDest(file)))
.on('unlink', (file) => { .on('unlink', (file) => fs.remove(toDest(file)))
fs.remove(toDest(file))
})

Loading…
Cancel
Save