-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcopyUntypedFiles.mjs
More file actions
36 lines (31 loc) · 866 Bytes
/
copyUntypedFiles.mjs
File metadata and controls
36 lines (31 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import path from 'path';
import chokidar from 'chokidar';
const srcDir = path.join(process.cwd(), 'src');
const libDir = path.join(process.cwd(), 'lib');
const ignoredPattern = /(?:__tests__|\.tsx?$)/;
async function copy() {
await fs.copy(srcDir, libDir, {
filter(testedPath) {
return !ignoredPattern.test(testedPath);
},
});
}
if (process.argv.includes('--watch')) {
const watcher = chokidar.watch(srcDir, {
ignored: ignoredPattern,
ignoreInitial: true,
persistent: true,
});
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) =>
watcher.on(event, copy),
);
} else {
await copy();
}