Commit e7b47198 authored by nano's avatar nano

fix async

parent 25dc957a
...@@ -112,7 +112,7 @@ export const UploadPackage = async (ctx: Context) => { ...@@ -112,7 +112,7 @@ export const UploadPackage = async (ctx: Context) => {
// 上传完, 打包 // 上传完, 打包
let bundled; let bundled;
queue.run(async (ctx, next) => { await queue.run(async (ctx, next) => {
bundled = await bundle(filename); bundled = await bundle(filename);
this.next(); this.next();
}); });
...@@ -187,7 +187,7 @@ const uploadPackageUrl = async (ctx: Context) => { ...@@ -187,7 +187,7 @@ const uploadPackageUrl = async (ctx: Context) => {
// 打包 // 打包
let bundled; let bundled;
queue.run(async (ctx, next) => { await queue.run(async (ctx, next) => {
bundled = await bundle(path.basename(file.path)); bundled = await bundle(path.basename(file.path));
this.next(); this.next();
}); });
......
...@@ -62,19 +62,18 @@ export class Queue { ...@@ -62,19 +62,18 @@ export class Queue {
return this; return this;
} }
run(task: Function): Queue { async run(task: Function) {
this.queue.push(task); this.queue.push(task);
this.next(); await this.next();
return this;
} }
next() { async next() {
while (this.running < this.concurrency && this.queue.length) { while (this.running < this.concurrency && this.queue.length) {
let task: Function | undefined = this.queue.shift(); let task: Function | undefined = this.queue.shift();
if (!task) { if (!task) {
return; return;
} }
task(this, () => { await task(this, () => {
this.running--; this.running--;
this.next(); 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