diff --git a/scripts/copy.js b/scripts/copy.js index dee4e044..898b708b 100644 --- a/scripts/copy.js +++ b/scripts/copy.js @@ -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)))