-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixbug no file exist check #12
Fixbug no file exist check #12
Conversation
@stevending1st |
fileExistCheck 返回的 false 将被 try catch 先捕捉到,直接先运行错误处理逻辑, 退出爬虫,造成爬虫失败。 逻辑将改为 这是不是新增爬虫(没文件是新增爬虫, 有文件则不是)。 #15 从原来的回调 ,变成这种 await promise相关结合,还是不太习惯。 |
@@ -31,6 +31,10 @@ const { | |||
const articleFileName = await haveRouterAddrmd(articleChildRouter); | |||
const htmlString = await (await nodeFetch(URL, options)).text(); | |||
const articleText = await HTMLtoMarkdown(htmlString); | |||
|
|||
if (await fileExistCheck(input.markDownFilePath + articleFileName)) { | |||
return Promise.reject("file has exist"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async 函数里可以用同步的思维写
throw new Error('file has exist');
exports.fileExistCheck = (path) => | ||
new Promise((resolve, reject) => { | ||
fs.existsSync(path)? resolve(true) : reject(false); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要什么东西都封装成 Promise 异步的……
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我只是看到里面代码大部分是这样的, 就想保持语法风格的统一。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我只是看到里面代码大部分是这样的, 就想保持语法风格的统一。
不能形式大于内容,过多异步也拖性能。
Checklist(清单):
Update index.md
)(我的 pull request 有一个详细的标题,而不是像“添加 index.md 文件这样的粗略标题”。)main
branch of this repo.(我的 pull rewuest 基于本仓库main
分支修改。)Closes #11