Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
courtney-sims committed Oct 22, 2024
1 parent bf57eb8 commit 983a2cd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33006,6 +33006,12 @@ const OutputEntryPagesDeployment = OutputEntryBase.merge(z.object({
* @returns All artifact files from the directory
*/
async function getWranglerArtifacts(artifactDirectory) {
try {
await (0,promises_namespaceObject.access)(artifactDirectory);
}
catch {
return [];
}
// read files in asset directory
const dirent = await (0,promises_namespaceObject.readdir)(artifactDirectory, {
withFileTypes: true,
Expand Down
9 changes: 9 additions & 0 deletions src/wranglerArtifactManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ describe("wranglerArtifactsManager", () => {
]);
mock.restore();
});
it("Returns an empty list when the output directory doesn't exist", async () => {
mock({
notTheDirWeWant:{}
})

const artifacts = await getWranglerArtifacts("./testOutputDir");
expect(artifacts).toEqual([]);
mock.restore();
})
});

describe("getDetailedPagesDeployOutput()", async () => {
Expand Down
10 changes: 9 additions & 1 deletion src/wranglerArtifactManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { open, readdir } from "fs/promises";
import { access, open, readdir } from "fs/promises";
import { z } from "zod";

const OutputEntryBase = z.object({
Expand Down Expand Up @@ -28,6 +28,13 @@ type OutputEntryPagesDeployment = z.infer<typeof OutputEntryPagesDeployment>;
export async function getWranglerArtifacts(
artifactDirectory: string,
): Promise<string[]> {

try {
await access(artifactDirectory)
} catch {
return []
}

// read files in asset directory
const dirent = await readdir(artifactDirectory, {
withFileTypes: true,
Expand All @@ -54,6 +61,7 @@ export async function getWranglerArtifacts(
export async function getDetailedPagesDeployOutput(
artifactDirectory: string,
): Promise<OutputEntryPagesDeployment | null> {

const artifactFilePaths = await getWranglerArtifacts(artifactDirectory);

for (let i = 0; i < artifactFilePaths.length; i++) {
Expand Down

0 comments on commit 983a2cd

Please sign in to comment.