-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreate_problem.js
More file actions
42 lines (30 loc) · 863 Bytes
/
Copy pathcreate_problem.js
File metadata and controls
42 lines (30 loc) · 863 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const fs = require("fs");
const path = require("path");
const { execFileSync } = require("child_process");
for (const probNum of process.argv.slice(2)) {
const template = `---
params:
boj: ${probNum}
bojTitle: 문제 제목
---
## 문제 내용
여기에 문제 내용 입력
### 입력
### 출력
## 문제 풀이
{{< details title="스포일러" closed="true" >}}
여기에 문제 풀이 입력
{{< /details >}}
`;
const probNumSplit = probNum.split("");
const fileName = probNumSplit.pop() + ".md";
const filePath = path.join("content", "problems", ...probNumSplit, fileName);
if (!fs.existsSync(filePath)) {
const dirName = path.dirname(filePath);
if (!fs.existsSync(dirName)) {
fs.mkdirSync(dirName, { recursive: true });
}
fs.writeFileSync(filePath, template);
}
execFileSync("code", ["-r", filePath]);
}