-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathpack.mts
38 lines (33 loc) · 969 Bytes
/
pack.mts
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
37
38
import * as fs from "node:fs";
import * as path from "node:path";
const files = ["example/.gitignore", "example/windows/.gitignore"];
/**
* Renames `.dotfile` to `_dotfile`.
*/
function renameDotFile(p: string): string {
return path.join(path.dirname(p), "_" + path.basename(p).substring(1));
}
/**
* `npm install` seems to be renaming `.gitignore` files to `.npmignore`.
* This breaks our templates (see
* https://github.com/microsoft/react-native-test-app/issues/1228). As a
* workaround, we'll rename the files ourselves, from `.gitignore` to
* `_gitignore`, to avoid any further attempts to mutate the package.
*/
const { [2]: script } = process.argv;
switch (script) {
case "pre": {
for (const f of files) {
fs.renameSync(f, renameDotFile(f));
}
break;
}
case "post": {
for (const f of files) {
fs.renameSync(renameDotFile(f), f);
}
break;
}
default:
throw new Error(`No such script: ${script}`);
}