Fix: build async bug
This commit is contained in:
		
							parent
							
								
									fdbf369454
								
							
						
					
					
						commit
						8bad0cffff
					
				
							
								
								
									
										46
									
								
								build.js
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								build.js
									
									
									
									
									
								
							@ -83,19 +83,20 @@ function dateFormat(fmt, date) {
 | 
				
			|||||||
  return fmt;
 | 
					  return fmt;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const t = new Date();
 | 
					async function main() {
 | 
				
			||||||
const buildTime = dateFormat("YYYY-mm-dd HH:MM:SS", t);
 | 
					  const t = new Date();
 | 
				
			||||||
const buildDir = "builds";
 | 
					  const buildTime = dateFormat("YYYY-mm-dd HH:MM:SS", t);
 | 
				
			||||||
 | 
					  const buildDir = "builds";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log(
 | 
					  console.log(
 | 
				
			||||||
    `[Build] BUILD_DIR=${buildDir}, VERSION=${version}, BUILD_TIME=${buildTime}`
 | 
					    `[Build] BUILD_DIR=${buildDir}, VERSION=${version}, BUILD_TIME=${buildTime}`
 | 
				
			||||||
);
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
clearFolder(buildDir);
 | 
					  clearFolder(buildDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
copyFolderRecursiveSync("addon", buildDir);
 | 
					  copyFolderRecursiveSync("addon", buildDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
esbuild
 | 
					  await esbuild
 | 
				
			||||||
    .build({
 | 
					    .build({
 | 
				
			||||||
      entryPoints: ["src/index.ts"],
 | 
					      entryPoints: ["src/index.ts"],
 | 
				
			||||||
      bundle: true,
 | 
					      bundle: true,
 | 
				
			||||||
@ -105,9 +106,9 @@ esbuild
 | 
				
			|||||||
    })
 | 
					    })
 | 
				
			||||||
    .catch(() => process.exit(1));
 | 
					    .catch(() => process.exit(1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log("[Build] Run esbuild OK");
 | 
					  console.log("[Build] Run esbuild OK");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const optionsAddon = {
 | 
					  const optionsAddon = {
 | 
				
			||||||
    files: [
 | 
					    files: [
 | 
				
			||||||
      path.join(buildDir, "**/*.rdf"),
 | 
					      path.join(buildDir, "**/*.rdf"),
 | 
				
			||||||
      path.join(buildDir, "**/*.dtd"),
 | 
					      path.join(buildDir, "**/*.dtd"),
 | 
				
			||||||
@ -143,29 +144,32 @@ const optionsAddon = {
 | 
				
			|||||||
      `<em:version>${version}</em:version>`,
 | 
					      `<em:version>${version}</em:version>`,
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    countMatches: true,
 | 
					    countMatches: true,
 | 
				
			||||||
};
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
_ = replace.sync(optionsAddon);
 | 
					  _ = replace.sync(optionsAddon);
 | 
				
			||||||
console.log(
 | 
					  console.log(
 | 
				
			||||||
    "[Build] Run replace in ",
 | 
					    "[Build] Run replace in ",
 | 
				
			||||||
    _.filter((f) => f.hasChanged).map(
 | 
					    _.filter((f) => f.hasChanged).map(
 | 
				
			||||||
      (f) => `${f.file} : ${f.numReplacements} / ${f.numMatches}`
 | 
					      (f) => `${f.file} : ${f.numReplacements} / ${f.numMatches}`
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
);
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log("[Build] Replace OK");
 | 
					  console.log("[Build] Replace OK");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log("[Build] Addon prepare OK");
 | 
					  console.log("[Build] Addon prepare OK");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
compressing.zip.compressDir(
 | 
					  compressing.zip.compressDir(
 | 
				
			||||||
    path.join(buildDir, "addon"),
 | 
					    path.join(buildDir, "addon"),
 | 
				
			||||||
    path.join(buildDir, `${name}.xpi`),
 | 
					    path.join(buildDir, `${name}.xpi`),
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      ignoreBase: true,
 | 
					      ignoreBase: true,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
);
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log("[Build] Addon pack OK");
 | 
					  console.log("[Build] Addon pack OK");
 | 
				
			||||||
console.log(
 | 
					  console.log(
 | 
				
			||||||
    `[Build] Finished in ${(new Date().getTime() - t.getTime()) / 1000} s.`
 | 
					    `[Build] Finished in ${(new Date().getTime() - t.getTime()) / 1000} s.`
 | 
				
			||||||
);
 | 
					  );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					main();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user