orc-scripts 1.6.1-dev.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/scripts/prep.js +38 -5
package/package.json
CHANGED
package/src/scripts/prep.js
CHANGED
|
@@ -4,11 +4,14 @@ const makeDir = require("make-dir");
|
|
|
4
4
|
|
|
5
5
|
const readdir = util.promisify(require("fs").readdir);
|
|
6
6
|
const copyFile = util.promisify(require("ncp").ncp);
|
|
7
|
+
const existsSync = require("fs").existsSync;
|
|
8
|
+
const stat = util.promisify(require("fs").stat);
|
|
7
9
|
|
|
8
10
|
const distDir = path.resolve(process.cwd(), "dist");
|
|
9
11
|
const contentDir = path.resolve(process.cwd(), "src/content");
|
|
10
12
|
const staticDir = path.resolve(process.cwd(), "src/static");
|
|
11
13
|
const mockDir = path.resolve(process.cwd(), "src/__mocks__");
|
|
14
|
+
const projectSpecificPrep = path.resolve(process.cwd(), "src/project-prep.json");
|
|
12
15
|
|
|
13
16
|
async function prep() {
|
|
14
17
|
await makeDir("dist");
|
|
@@ -18,11 +21,41 @@ async function prep() {
|
|
|
18
21
|
copyFile(mockDir, path.resolve(distDir, "__mocks__")),
|
|
19
22
|
]);
|
|
20
23
|
} catch (_) {}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
if (process.env.NODE_ENV === "production") {
|
|
26
|
+
// production build will not copy the static files
|
|
27
|
+
} else {
|
|
28
|
+
try {
|
|
29
|
+
const files = await readdir(staticDir);
|
|
30
|
+
await Promise.all(files.map(file => copyFile(path.resolve(staticDir, file), path.resolve(distDir, file))));
|
|
31
|
+
} catch (_) {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (existsSync(projectSpecificPrep)) {
|
|
35
|
+
const additionalFiles = require(projectSpecificPrep);
|
|
36
|
+
|
|
37
|
+
if (additionalFiles && additionalFiles.length > 0) {
|
|
38
|
+
additionalFiles.forEach(async fileInfo => {
|
|
39
|
+
const sourceFile = path.resolve(process.cwd(), fileInfo.src);
|
|
40
|
+
const fileStat = await stat(sourceFile);
|
|
41
|
+
|
|
42
|
+
if (fileStat.isDirectory()) {
|
|
43
|
+
const files = await readdir(sourceFile);
|
|
44
|
+
await makeDir(path.resolve(distDir, fileInfo.dest));
|
|
45
|
+
await Promise.all(
|
|
46
|
+
files.map(file => copyFile(path.resolve(sourceFile, file), path.resolve(distDir, fileInfo.dest, file))),
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
const destFile = path.resolve(distDir, fileInfo.dest, path.basename(fileInfo.src));
|
|
50
|
+
const destDir = path.dirname(destFile);
|
|
51
|
+
await makeDir(destDir);
|
|
52
|
+
await copyFile(sourceFile, destFile);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
console.log("nay");
|
|
58
|
+
}
|
|
26
59
|
}
|
|
27
60
|
|
|
28
61
|
prep();
|