mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-21 17:43:23 +01:00
Update snapshot for checkWorkingDirectory test
This commit is contained in:
parent
e5251df521
commit
105f191b19
2 changed files with 10 additions and 24 deletions
|
@ -47,18 +47,10 @@ describe("checkWorkingDirectory", () => {
|
|||
});
|
||||
|
||||
test("should fail if the directory does not exist", () => {
|
||||
try {
|
||||
checkWorkingDirectory("/does/not/exist");
|
||||
} catch (error) {
|
||||
expect(error.message).toMatchInlineSnapshot();
|
||||
}
|
||||
});
|
||||
|
||||
test("should fail if an error occurs while checking/creating the directory", () => {
|
||||
try {
|
||||
checkWorkingDirectory("/does/not/exist");
|
||||
} catch (error) {
|
||||
expect(error.message).toMatchInlineSnapshot();
|
||||
}
|
||||
expect(() =>
|
||||
checkWorkingDirectory("/does/not/exist"),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
'"Directory /does/not/exist does not exist."',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
16
src/index.ts
16
src/index.ts
|
@ -113,17 +113,11 @@ async function runProcess(
|
|||
}
|
||||
|
||||
function checkWorkingDirectory(workingDirectory = ".") {
|
||||
try {
|
||||
const normalizedPath = path.normalize(workingDirectory);
|
||||
if (existsSync(normalizedPath)) {
|
||||
return normalizedPath;
|
||||
} else {
|
||||
throw new Error(`Directory ${workingDirectory} does not exist.`);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`While checking/creating directory ${workingDirectory} received ${error}`,
|
||||
);
|
||||
const normalizedPath = path.normalize(workingDirectory);
|
||||
if (existsSync(normalizedPath)) {
|
||||
return normalizedPath;
|
||||
} else {
|
||||
throw new Error(`Directory ${workingDirectory} does not exist.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue