-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathutil.ts
More file actions
41 lines (37 loc) · 1.12 KB
/
Copy pathutil.ts
File metadata and controls
41 lines (37 loc) · 1.12 KB
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
39
40
41
import { execSync } from "child_process";
import { writeFileSync } from "fs";
import path from "path";
import { exit } from "process";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const $ = (command: string) => {
try {
return execSync(command);
} catch (e) {
exit(1);
}
};
const labels = {
object: "🧩", // Puzzle piece to represent an object
descriptor: "📝", // Memo to represent a descriptor
enum: "🔢", // Input numbers to represent an enumeration
union: "🔗", // Link symbol to represent a union of types
errors: "🚨", // Warning sign to represent errors
};
export const writeFile = (
label: keyof typeof labels,
name: string,
content: string,
) => {
const descriptors = label === "object" ? false : true;
const file = path.resolve(
__dirname,
`../../cpp/rnwgpu/api/${descriptors ? "descriptors" : ""}/${name}.h`,
);
$(`touch ${file}`);
writeFileSync(file, content, "utf8");
console.log(
`${labels[label]} ${file.substring(file.indexOf("/package/") + "/package/".length)}`,
);
};