-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-day.ts
46 lines (35 loc) · 966 Bytes
/
build-day.ts
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
42
43
44
45
46
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const folderName = process.argv[2];
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
if (!folderName) {
console.error("Please provide a folder name as the first argument.");
process.exit(1);
}
const folderPath = path.join(__dirname, folderName);
if (fs.existsSync(folderPath)) {
console.log(`Folder '${folderName}' already exists. No action taken.`);
process.exit(0);
}
fs.mkdirSync(folderPath, { recursive: true });
const files = [
{
name: "solution.ts",
content: `
function part_1(input:string){};
function part_2(input:string){};
export {
part_1,
part_2
}
`,
},
{ name: "puzzle.txt", content: "" },
];
files.forEach((file) => {
const filePath = path.join(folderPath, file.name);
fs.writeFileSync(filePath, file.content);
});
console.log(`Folder '${folderName}' and files created successfully.`);