Commit e7b47198 authored by nano's avatar nano

fix async

parent 25dc957a
......@@ -112,7 +112,7 @@ export const UploadPackage = async (ctx: Context) => {
// 上传完, 打包
let bundled;
queue.run(async (ctx, next) => {
await queue.run(async (ctx, next) => {
bundled = await bundle(filename);
this.next();
});
......@@ -187,7 +187,7 @@ const uploadPackageUrl = async (ctx: Context) => {
// 打包
let bundled;
queue.run(async (ctx, next) => {
await queue.run(async (ctx, next) => {
bundled = await bundle(path.basename(file.path));
this.next();
});
......
......@@ -62,19 +62,18 @@ export class Queue {
return this;
}
run(task: Function): Queue {
async run(task: Function) {
this.queue.push(task);
this.next();
return this;
await this.next();
}
next() {
async next() {
while (this.running < this.concurrency && this.queue.length) {
let task: Function | undefined = this.queue.shift();
if (!task) {
return;
}
task(this, () => {
await task(this, () => {
this.running--;
this.next();
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment