Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ece371b

Browse files
refactor: readme 로직 단순화
1 parent 32a063b commit ece371b

File tree

4 files changed

+32
-84
lines changed

4 files changed

+32
-84
lines changed

‎utils/api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import fs from 'fs';
2-
import { splitCodeToSolutions } from './format.js';
2+
const splitCodeToSolutions = code => {
3+
if (code === undefined) return [];
4+
const solutions = code.split(/\/\/[]*/);
5+
return [solutions[0], ...solutions.slice(1).map(solution => '//' + solution)];
6+
};
37

48
export const generateAPI = () => {
59
try {

‎utils/build.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import * as fs from 'fs';
2-
import path from 'path';
3-
import { getTableStr, getInfoList } from './string.js';
4-
5-
const __dirname = path.resolve();
6-
const FILE_TO_UPDATE = path.resolve(__dirname, './README.md');
7-
const updateData = `# 프로그래머스 모든 문제 풀이
1+
import fs from 'fs';
2+
import { generateAPI } from './api.js';
3+
const generateTables = () => {
4+
const files = generateAPI();
5+
return [1, 2, 3, 4, 5].map(level =>
6+
files
7+
.filter(file => file.level === level)
8+
.map(({ level, fileName, name, fileLink }, index) => {
9+
const fileLink = `https://github.com/codeisneverodd/programmers-coding-test/blob/main/level-${level}/${fileName}`;
10+
return `| ${index + 1} | [${name}](${link}) | [${name}.js](${fileLink}) |`;
11+
})
12+
);
13+
};
14+
const tables = generateTables();
15+
16+
const newREADME = `# 프로그래머스 모든 문제 풀이
817
[![방문자수](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/codeisneverodd/programmers-coding-test&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=방문자수(Today/Total)&edge_flat=true)](https://github.com/codeisneverodd)
918
## 👋 소개
1019
- 🌱 모든 문제는 JavaScript로 풀이되고 다양한 사람의 풀이가 올라와있어요
@@ -34,47 +43,47 @@ const updateData = `# 프로그래머스 모든 문제 풀이
3443
### Level 1 ✅
3544
3645
- 전체 문제 수: 56문제
37-
- 풀이 문제 수: ${getInfoList(1).length}문제
46+
- 풀이 문제 수: ${tables[0].length}문제
3847
3948
| 번호 | 문제 출처 | 풀이 |
4049
| --- | ------- | --- |
41-
${getTableStr(1)}
50+
${tables[0].join('\n')}
4251
4352
### Level 2 👨🏻‍💻(풀이 중..)
4453
4554
- 전체 문제 수: 65문제
46-
- 풀이 문제 수: ${getInfoList(2).length}문제
55+
- 풀이 문제 수: ${tables[1].length}문제
4756
4857
| 번호 | 문제 출처 | 풀이 |
4958
| --- | ------- | --- |
50-
${getTableStr(2)}
59+
${tables[1].join('\n')}
5160
5261
### Level 3 👨🏻‍💻(풀이 중..)
5362
5463
- 전체 문제 수: 52문제
55-
- 풀이 문제 수: ${getInfoList(3).length}문제
64+
- 풀이 문제 수: ${tables[2].length}문제
5665
5766
| 번호 | 문제 출처 | 풀이 |
5867
| --- | ------- | --- |
59-
${getTableStr(3)}
68+
${tables[2].join('\n')}
6069
6170
### Level 4
6271
6372
- 전체 문제 수: 22문제
64-
- 풀이 문제 수: ${getInfoList(4).length}문제
73+
- 풀이 문제 수: ${tables[3].length}문제
6574
6675
| 번호 | 문제 출처 | 풀이 |
6776
| --- | ------- | --- |
68-
${getTableStr(4)}
77+
${tables[3].join('\n')}
6978
7079
### Level 5
7180
7281
- 전체 문제 수: 6문제
73-
- 풀이 문제 수: ${getInfoList(5).length}문제
82+
- 풀이 문제 수: ${tables[4].length}문제
7483
7584
| 번호 | 문제 출처 | 풀이 |
7685
| --- | ------- | --- |
77-
${getTableStr(5)}
86+
${tables[4].join('\n')}
7887
7988
## 🙏🏻 아직 풀리지 않은 문제의 해답을 추가해 주세요!
8089
### 커밋 컨벤션
@@ -107,4 +116,4 @@ ${getTableStr(5)}
107116
를 명시하여야합니다.
108117
`;
109118

110-
fs.writeFileSync(FILE_TO_UPDATE,updateData, 'utf-8');
119+
fs.writeFileSync('./README.md',newREADME, 'utf-8');

‎utils/format.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎utils/string.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /