evshiron лет назад: 8
Родитель
Сommit
5bfa4a16c1
1 измененных файлов с 16 добавлено и 7 удалено
  1. 16 7
      src/lib/Builder.ts

+ 16 - 7
src/lib/Builder.ts

@@ -77,7 +77,7 @@ export class Builder {
 
         if(this.options.concurrent) {
 
-            await Bluebird.map(tasks, async ([ platform, arch ], idx) => {
+            await Bluebird.map(tasks, async ([ platform, arch ]) => {
 
                 const options: any = {};
                 options[platform] = true;
@@ -93,7 +93,7 @@ export class Builder {
                 await builder.build();
 
                 if(!this.options.mute) {
-                    console.info(`Building for ${ platform }, ${ arch } ends within ${ ((Date.now() - started) / 1000).toFixed(2) }ms.`);
+                    console.info(`Building for ${ platform }, ${ arch } ends within ${ this.getTimeDiff(started) }ms.`);
                 }
 
             });
@@ -113,7 +113,7 @@ export class Builder {
                 await this.buildTask(platform, arch, pkg, config);
 
                 if(!this.options.mute) {
-                    console.info(`Building for ${ platform }, ${ arch } ends within ${ ((Date.now() - started) / 1000).toFixed(2) }ms.`);
+                    console.info(`Building for ${ platform }, ${ arch } ends within ${ this.getTimeDiff(started) }ms.`);
                 }
 
             }
@@ -122,6 +122,10 @@ export class Builder {
 
     }
 
+    protected getTimeDiff(started: number) {
+        return ((Date.now() - started) / 1000).toFixed(2);
+    }
+
     protected combineExecutable(executable: string, nwFile: string) {
         return new Promise((resolve, reject) => {
 
@@ -577,24 +581,29 @@ export class Builder {
 
         const targetDir = await this.buildDirTarget(platform, arch, runtimeDir, pkg, config);
 
+        // TODO: Consider using `Bluebird.map` to enable concurrent target building.
         for(const target of config.targets) {
+
+            const started = Date.now();
+
             switch(target) {
             case 'zip':
             case '7z':
+                await this.buildArchiveTarget(target, targetDir);
                 if(!this.options.mute) {
-                    console.info(`Building ${ target } archive target...`);
+                    console.info(`Building ${ target } archive target ends within ${ this.getTimeDiff(started) }ms.`);
                 }
-                await this.buildArchiveTarget(target, targetDir);
                 break;
             case 'nsis':
+                await this.buildNsisTarget(platform, arch, targetDir, pkg, config);
                 if(!this.options.mute) {
-                    console.info(`Building nsis target...`);
+                    console.info(`Building nsis target ends within ${ this.getTimeDiff(started) }.`);
                 }
-                await this.buildNsisTarget(platform, arch, targetDir, pkg, config);
                 break;
             default:
                 throw new Error('ERROR_UNKNOWN_TARGET');
             }
+
         }
 
     }