This repository has been archived by the owner on Jul 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lucas Bersier
committed
Dec 14, 2018
1 parent
2c3c2f4
commit 2fa19a5
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const fs = require('fs'); | ||
const rootFolder = process.argv[2]; | ||
let booklist = fs.readdirSync(rootFolder); | ||
|
||
let books = []; | ||
|
||
booklist.forEach(book => { | ||
let bookData = fs.readFileSync(`${rootFolder}/${book}/data.txt`) | ||
.toString() | ||
.split('\n'); | ||
|
||
let bookObj = { | ||
folder: `${rootFolder}/${book}`, | ||
name: bookData[0], | ||
kanji: bookData[1], | ||
author: bookData[2], | ||
TL: bookData[3], | ||
BG: bookData[4], | ||
BBG: bookData[5] | ||
}; | ||
|
||
bookObj.chapters = fs.readdirSync(bookObj.folder) | ||
.filter(chapter => { | ||
return fs.lstatSync(`${rootFolder}/${book}/${chapter}`).isDirectory() | ||
}); | ||
|
||
books.push(bookObj); | ||
}); | ||
|
||
fs.writeFile('./BOOKLIST.js', 'var books = '+JSON.stringify(books), err => { | ||
if (err){ | ||
return console.log('Unable to generate booklist file\n' + err) | ||
} else { | ||
console.log('Booklist generated!\nRun \'yarn run build\' next'); | ||
} | ||
}); |