Skip to content

Commit

Permalink
Made deleting async
Browse files Browse the repository at this point in the history
  • Loading branch information
dev2-nomo committed Dec 1, 2023
1 parent 8f4d0f0 commit fdba196
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
29 changes: 18 additions & 11 deletions src/build-webon/build-webon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function checkRequiredFiles(outDirPath: string): string[] {
return requiredFiles.filter((file) => !existsSync(file));
}

export function deleteExistingTarFile(tarFilePath: string): void {
export async function deleteExistingTarFile(
tarFilePath: string
): Promise<void> {
if (existsSync(tarFilePath)) {
unlinkSync(tarFilePath);
}
Expand Down Expand Up @@ -60,7 +62,7 @@ export async function buildWebOn(assetDir: string): Promise<void> {
const tarFileName = "nomo.tar.gz";
const tarFilePath = path.join(outDirPath, tarFileName);

deleteExistingTarFile(tarFilePath);
await deleteExistingTarFile(tarFilePath);

try {
await createTarFile(outDirPath, tarFilePath);
Expand All @@ -74,14 +76,19 @@ async function createTarFile(
outDirPath: string,
tarFilePath: string
): Promise<void> {
// console.log( `Creating new webon ${path.basename(tarFilePath)}: ${tarFilePath}`);

await tar.create(
{
file: tarFilePath,
gzip: true,
cwd: path.dirname(outDirPath),
},
[path.basename(outDirPath)]
console.log(
`Creating new webon ${path.basename(tarFilePath)}: ${tarFilePath}`
);
try {
await tar.create(
{
file: tarFilePath,
gzip: true,
cwd: path.dirname(outDirPath),
},
[path.basename(outDirPath)]
);
} catch (e) {
console.log("Building tar failed " + e);
}
}
4 changes: 2 additions & 2 deletions test/e2e/build-webon-test/packaging-completed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
jest.setTimeout(30000);
test("successful tar.gz build", async () => {
const output = await runE2ETest("build test_assets/out/");
await new Promise((resolve) => setTimeout(resolve, 2000));
await new Promise((resolve) => setTimeout(resolve, 5000));
expect(output).toContain("Build and packaging completed!");
const existsFile = fs.existsSync("test_assets/out/nomo.tar.gz");
expect(existsFile).toBe(true);
await new Promise((resolve) => setTimeout(resolve, 2000));
await new Promise((resolve) => setTimeout(resolve, 5000));
fs.unlinkSync("test_assets/out/nomo.tar.gz");
});

Expand Down

0 comments on commit fdba196

Please sign in to comment.