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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const t = new Date();
 | 
			
		||||
const buildTime = dateFormat("YYYY-mm-dd HH:MM:SS", t);
 | 
			
		||||
const buildDir = "builds";
 | 
			
		||||
async function main() {
 | 
			
		||||
  const t = new Date();
 | 
			
		||||
  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}`
 | 
			
		||||
);
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
clearFolder(buildDir);
 | 
			
		||||
  clearFolder(buildDir);
 | 
			
		||||
 | 
			
		||||
copyFolderRecursiveSync("addon", buildDir);
 | 
			
		||||
  copyFolderRecursiveSync("addon", buildDir);
 | 
			
		||||
 | 
			
		||||
esbuild
 | 
			
		||||
  await esbuild
 | 
			
		||||
    .build({
 | 
			
		||||
      entryPoints: ["src/index.ts"],
 | 
			
		||||
      bundle: true,
 | 
			
		||||
@ -105,9 +106,9 @@ esbuild
 | 
			
		||||
    })
 | 
			
		||||
    .catch(() => process.exit(1));
 | 
			
		||||
 | 
			
		||||
console.log("[Build] Run esbuild OK");
 | 
			
		||||
  console.log("[Build] Run esbuild OK");
 | 
			
		||||
 | 
			
		||||
const optionsAddon = {
 | 
			
		||||
  const optionsAddon = {
 | 
			
		||||
    files: [
 | 
			
		||||
      path.join(buildDir, "**/*.rdf"),
 | 
			
		||||
      path.join(buildDir, "**/*.dtd"),
 | 
			
		||||
@ -143,29 +144,32 @@ const optionsAddon = {
 | 
			
		||||
      `<em:version>${version}</em:version>`,
 | 
			
		||||
    ],
 | 
			
		||||
    countMatches: true,
 | 
			
		||||
};
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
_ = replace.sync(optionsAddon);
 | 
			
		||||
console.log(
 | 
			
		||||
  _ = replace.sync(optionsAddon);
 | 
			
		||||
  console.log(
 | 
			
		||||
    "[Build] Run replace in ",
 | 
			
		||||
    _.filter((f) => f.hasChanged).map(
 | 
			
		||||
      (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, `${name}.xpi`),
 | 
			
		||||
    {
 | 
			
		||||
      ignoreBase: true,
 | 
			
		||||
    }
 | 
			
		||||
);
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
console.log("[Build] Addon pack OK");
 | 
			
		||||
console.log(
 | 
			
		||||
  console.log("[Build] Addon pack OK");
 | 
			
		||||
  console.log(
 | 
			
		||||
    `[Build] Finished in ${(new Date().getTime() - t.getTime()) / 1000} s.`
 | 
			
		||||
);
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user