diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..c0c9bb3
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,18 @@
+module.exports = {
+ root: true,
+ parserOptions: {
+ ecmaVersion: 'latest'
+ },
+ env: {
+ es6: true,
+ node: true
+ },
+ extends: 'eslint:recommended',
+ rules: {
+ quotes: [
+ 'error',
+ 'single'
+ ],
+ 'no-unused-vars': 'warn',
+ }
+}
diff --git a/lib/download.js b/lib/download.js
index b0c4a14..b697c9b 100644
--- a/lib/download.js
+++ b/lib/download.js
@@ -141,7 +141,7 @@ class Downloader {
console.log('image src:', src, '\n');
// 按照cdn的url规则,获取图片名称
// https://cdn.nlark.com/yuque/0/2024/png/394019/1713409985862-2a651a60-380a-4227-852c-e81d193340c5.png#averageHue=%23f8f9fa&clientId=u7b4c5a0c-9e50-4&from=ui&id=u0437de00&originHeight=48&originWidth=48&originalType=binary&ratio=2&rotation=0&showTitle=false&size=1428&status=done&style=none&taskId=ufab6517c-e059-4e38-8cef-b2ddf4390f8&title=
- const pathname = new URL(url).pathname;
+ const pathname = new URL(src).pathname;
const fileName = pathname.split('.').shift();
const name = `${repo_name}_${slug}_image_${fileName}`
const imageUrl = await this.uploadImageFromUrl(src, name);
diff --git a/lib/index.js b/lib/index.js
index 9cf67c7..78e9b07 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -6,15 +6,12 @@ const { YUQUE_REPOS } = process.env;
async function run () {
if (!YUQUE_REPOS) {
throw new Error ('Need YUQUE_REPOS');
- };
+ }
const repos = YUQUE_REPOS.split(',');
- await Promise.all(repos.map((repo) => {
- return new Promise(async(resolve) => {
- const downloader = new Downloader(repo)
- await downloader.autoUpdate();
- resolve();
- });
+ await Promise.all(repos.map(async (repo) => {
+ const downloader = new Downloader(repo)
+ await downloader.autoUpdate();
}))
const gh = new GitHubClient()
diff --git a/lib/utils.js b/lib/utils.js
index dd9749c..5961ddf 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -37,7 +37,7 @@ exports.formatRaw = function (body) {
const brBug = /
/g;
const hiddenContent = /