Update snapshot for checkWorkingDirectory test

This commit is contained in:
Cina Saffary 2023-08-29 17:43:29 -05:00
parent e5251df521
commit 105f191b19
2 changed files with 10 additions and 24 deletions

View file

@ -47,18 +47,10 @@ describe("checkWorkingDirectory", () => {
}); });
test("should fail if the directory does not exist", () => { test("should fail if the directory does not exist", () => {
try { expect(() =>
checkWorkingDirectory("/does/not/exist"); checkWorkingDirectory("/does/not/exist"),
} catch (error) { ).toThrowErrorMatchingInlineSnapshot(
expect(error.message).toMatchInlineSnapshot(); '"Directory /does/not/exist does not exist."',
} );
});
test("should fail if an error occurs while checking/creating the directory", () => {
try {
checkWorkingDirectory("/does/not/exist");
} catch (error) {
expect(error.message).toMatchInlineSnapshot();
}
}); });
}); });

View file

@ -113,18 +113,12 @@ async function runProcess(
} }
function checkWorkingDirectory(workingDirectory = ".") { function checkWorkingDirectory(workingDirectory = ".") {
try {
const normalizedPath = path.normalize(workingDirectory); const normalizedPath = path.normalize(workingDirectory);
if (existsSync(normalizedPath)) { if (existsSync(normalizedPath)) {
return normalizedPath; return normalizedPath;
} else { } else {
throw new Error(`Directory ${workingDirectory} does not exist.`); throw new Error(`Directory ${workingDirectory} does not exist.`);
} }
} catch (error) {
throw new Error(
`While checking/creating directory ${workingDirectory} received ${error}`,
);
}
} }
function installWrangler() { function installWrangler() {