Skip to content
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

Review 1124 #1

Open
zxc0328 opened this issue Nov 24, 2018 · 0 comments
Open

Review 1124 #1

zxc0328 opened this issue Nov 24, 2018 · 0 comments

Comments

@zxc0328
Copy link
Member

zxc0328 commented Nov 24, 2018

需要改进的:

代码层面 f9c9cef

此外,需要用 Mocha 补上单元测试,然后设置好 CI

其他:

const command = async () => {
    const pathArr = await getFiles(path);
    const bar = barFn(pathArr.length);
    logger.log(`the file you will push:`, `blue`);
    console.log(`[qiniu-upload-tool] ${pathArr}`);
    pathArr.forEach(file => {
      push(file).then(bar.tick());
    });
    logger.success(`successfully!`);
  };

这里何必要用 async,getFiles 是同步的操作。

upload 这个函数,可以直接通过 CLI 调用,也应该暴露出去,让 JS 可以直接作为 API 调用。所以这个是一个异步的 API,肯定要返回 Promise。

所以 upload 需要返回一个 Promise,最后上传成功应该返回一些信息,如果内部有错误也应该 reject Promise。在单测里面就是直接引入 upload 进行测试的。

upload 需要有一个参数,代表是否是在 CLI 里调用,只有在 CLI 调用的时候会做一些信息的 Logging。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant