-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathcopyFiles.js
More file actions
27 lines (20 loc) · 852 Bytes
/
copyFiles.js
File metadata and controls
27 lines (20 loc) · 852 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
// @ts-check
const { execSync } = require("child_process");
const { existsSync } = require("fs");
const { join, extname } = require("path");
const fse = require("fs-extra");
const copyDir = join(__dirname, "..", "copy");
const jsonDir = join(__dirname, "..", "generated");
const outDir = join(__dirname, "..", "..", "typescriptlang-org", "public", "js", "examples");
if (!existsSync(outDir)) execSync(`mkdir -p ${outDir}`);
// Move samples
fse.copySync(copyDir, outDir);
/**
* Filter logic, will be included if return true. However, we must skip the source dir as stated on
* https://github.com/jprichardson/node-fs-extra/issues/741#issuecomment-579629747
*/
const filterFunc = src => {
return src === jsonDir || extname(src) === ".json";
};
// Move the JSON files which are generated
fse.copySync(jsonDir, outDir, { filter: filterFunc });