Skip to content

Commit 9b84cd2

Browse files
committed
Add Dir Not Found Create method
1 parent 3cd8c29 commit 9b84cd2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { Command } = require('commander');
2+
const fs = require('fs');
23
const Crawler = require('./crawler');
34

45
const program = new Command();
@@ -8,6 +9,11 @@ program.option('-u, --username <username>', 'velog 유저이름');
89

910
program.parse(process.argv);
1011

12+
!fs.existsSync('./backup') && fs.mkdirSync('./backup');
13+
!fs.existsSync('./backup/content') && fs.mkdirSync('./backup/content');
14+
!fs.existsSync('./backup/images') && fs.mkdirSync('./backup/images');
15+
1116
const crawler = new Crawler(program.username);
1217

13-
JSON.stringify(crawler.parse());
18+
console.log('📙 백업을 시작합니다 / velog-backup')
19+
crawler.parse()

crawler/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ class Crawler {
1616

1717
posts.map(async(postInfo, i) => {
1818
let post = await this.getPost(postInfo.url_slug);
19-
2019
post.body = await this.getImage(post.body);
21-
await this.writePost(post);
2220

23-
console.log(`✅ " ${post.title} " 백업 (${i + 1}/${posts.length})`);
21+
await this.writePost(post);
22+
console.log(`✅ " ${post.title} " 백업 완료`);
2423
});
25-
2624
}
2725

2826
async getPosts() {

0 commit comments

Comments
 (0)