forked from Anduin2017/HowToCook
-
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
Showing
37 changed files
with
260 additions
and
117 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 |
---|---|---|
@@ -1,63 +1,53 @@ | ||
// fetch all .md files. | ||
// Check it's content. | ||
// Console.LogError for errors. | ||
|
||
|
||
const glob = require("glob"); | ||
const fs = require("fs"); | ||
var path = require('path'); | ||
|
||
var errors = 0; | ||
|
||
var getDirectories = function (src, callback) { | ||
glob(src + '../../dishes/**/*.md', callback); | ||
}; | ||
|
||
getDirectories(__dirname, function (err, res) { | ||
res.forEach(filePath => { | ||
// console.log("Linting file: " + filePath + " ..."); | ||
|
||
fs.readFile(filePath, 'utf8' , (err, data) => { | ||
data = data.replace('\r\n', '\n'); | ||
data = data.replace('\r', '\n'); | ||
|
||
dataLines = data.split('\n'); | ||
var filename = path.parse(filePath).base.replace(".md",""); | ||
|
||
titles = dataLines.filter(t => t.startsWith('#')); | ||
secondTitles = titles | ||
.filter(t => t.startsWith('## ')); | ||
|
||
if (titles[0].trim() != "# " + filename + "的做法") { | ||
console.error(`File ${filePath} is invalid! It's title should be: ${"# " + filename + "的做法"}! It was ${titles[0].trim()}!`); | ||
errors++; | ||
return; | ||
} | ||
if (secondTitles.length != 4) { | ||
console.error(`File ${filePath} is invalid! It doesn't has 4 second titles!`); | ||
errors++; | ||
return; | ||
} | ||
if (secondTitles[0].trim() != "## 必备原料和工具") { | ||
console.error(`File ${filePath} is invalid! The first title is NOT 必备原料和工具! It was ${secondTitles[0]}!`); | ||
errors++; | ||
} | ||
if (secondTitles[1].trim() != "## 计算") { | ||
console.error(`File ${filePath} is invalid! The second title is NOT 计算!`); | ||
errors++; | ||
} | ||
if (secondTitles[2].trim() != "## 操作") { | ||
console.error(`File ${filePath} is invalid! The thrid title is NOT 操作!`); | ||
errors++; | ||
} | ||
if (secondTitles[3].trim() != "## 附加内容") { | ||
console.error(`File ${filePath} is invalid! The fourth title is NOT 附加内容!`); | ||
errors++; | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
if (errors > 0) { | ||
throw `Found ${errors} errors! Please fix!`; | ||
} | ||
const util = require("util"); | ||
const glob = util.promisify(require('glob')); | ||
const fs = require("fs").promises; | ||
const path = require('path'); | ||
|
||
|
||
async function main() { | ||
var errors = []; | ||
var directories = await glob(__dirname + '../../dishes/**/*.md'); | ||
|
||
for (var filePath of directories) { | ||
var data = await fs.readFile(filePath, 'utf8'); | ||
|
||
dataLines = data.split('\n').map(t => t.trim()); | ||
var filename = path.parse(filePath).base.replace(".md",""); | ||
|
||
titles = dataLines.filter(t => t.startsWith('#')); | ||
secondTitles = titles | ||
.filter(t => t.startsWith('## ')); | ||
|
||
if (titles[0].trim() != "# " + filename + "的做法") { | ||
errors.push(`File ${filePath} is invalid! It's title should be: ${"# " + filename + "的做法"}! It was ${titles[0].trim()}!`); | ||
continue; | ||
} | ||
if (secondTitles.length != 4) { | ||
errors.push(`File ${filePath} is invalid! It doesn't has 4 second titles!`); | ||
continue; | ||
} | ||
if (secondTitles[0].trim() != "## 必备原料和工具") { | ||
errors.push(`File ${filePath} is invalid! The first title is NOT 必备原料和工具! It was ${secondTitles[0]}!`); | ||
} | ||
if (secondTitles[1].trim() != "## 计算") { | ||
errors.push(`File ${filePath} is invalid! The second title is NOT 计算!`); | ||
} | ||
if (secondTitles[2].trim() != "## 操作") { | ||
errors.push(`File ${filePath} is invalid! The thrid title is NOT 操作!`); | ||
} | ||
if (secondTitles[3].trim() != "## 附加内容") { | ||
errors.push(`File ${filePath} is invalid! The fourth title is NOT 附加内容!`); | ||
} | ||
} | ||
|
||
if (errors.length > 0) { | ||
for (var error of errors) { | ||
console.error(error + "\n"); | ||
} | ||
|
||
var message = `Found ${errors.length} errors! Please fix!`; | ||
throw new Error(message); | ||
} | ||
} | ||
|
||
main(); |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 吐司+果酱的做法 | ||
# 吐司果酱的做法 | ||
|
||
饱腹感的懒人快速营养早餐,2min 搞定 | ||
|
||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# 微波炉"叮"蛋糕的做法 | ||
# 微波炉蛋糕的做法 | ||
|
||
不必慌张, 你有十分充足的时间来准备, 可以根据心情加料, 大约需要 2min | ||
微波炉"叮"蛋糕,大约需要 2min 就能搞定! | ||
|
||
## 必备原料和工具 | ||
|
||
|
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
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 |
---|---|---|
|
@@ -5,6 +5,15 @@ | |
|
||
## 必备原料和工具 | ||
|
||
- 鸡蛋 | ||
- 全脂牛奶/奶油 | ||
- 黄油 | ||
- 盐 | ||
|
||
## 计算 | ||
|
||
每份: | ||
|
||
- 鸡蛋 3 个 | ||
- 全脂牛奶/奶油 10g | ||
- 黄油 5 克 | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 蒸花卷 | ||
# 蒸花卷的做法 | ||
|
||
蒸花卷是一道简单易做的菜。能补充碳水化合物,膳食纤维。一般初学者只需要半小时即可完成。作为快手早餐,学会做之后,再也不会早上饿肚子了。 | ||
|
||
|
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 |
---|---|---|
|
@@ -4,6 +4,16 @@ | |
|
||
## 必备原料和工具 | ||
|
||
- 鸡蛋 | ||
- 吐司 | ||
- 培根 | ||
- 黄油 | ||
- 蛋黄酱 | ||
- 盐 | ||
- 黑胡椒 | ||
|
||
## 计算 | ||
|
||
- 鸡蛋 1 个 | ||
- 吐司 2 片 | ||
- 培根 2 片 | ||
|
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 草莓的做法 | ||
# 草莓酱的做法 | ||
|
||
可以买那种一筐一筐卖的小草莓,主要是便宜。做成酱抹在面包上非常好吃。 | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 蒜香豉油的做法 | ||
# 蒜香酱油的做法 | ||
|
||
## 必备原料和工具 | ||
|
||
|
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
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 酸梅汁的做法 | ||
# 酸梅汤(半成品加工)的做法 | ||
|
||
## 必备原料和工具 | ||
|
||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
- 生抽酱油 | ||
- 味精 | ||
|
||
### 计算 | ||
## 计算 | ||
|
||
- 五花肉的用量为 0.5 斤/男人 0.3 斤/女人 (正宗回锅肉使用二刀肉[俗称:臀尖]制作,肉质坚实,肥瘦合适) | ||
- 小葱 2 棵 | ||
|
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
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
- 植物油 | ||
- 芝麻油 | ||
|
||
## 可选原料 | ||
### 可选原料 | ||
|
||
- 油泼辣子 | ||
- 莴笋 | ||
|
Oops, something went wrong.