-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows for node and bun, add tasks, add tests, add isDir,isFil…
…e and isSymlink.
- Loading branch information
Showing
10 changed files
with
172 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
deno_ci: | ||
uses: cross-org/workflows/.github/workflows/deno-ci.yml@main | ||
with: | ||
entrypoint: mod.ts | ||
bun_ci: | ||
uses: cross-org/workflows/.github/workflows/bun-ci.yml@main | ||
with: | ||
jsr_dependencies: "@cross/test @std/assert @cross/runtime" | ||
node_ci: | ||
uses: cross-org/workflows/.github/workflows/node-ci.yml@main | ||
with: | ||
jsr_dependencies: "@cross/test @std/assert @cross/runtime" | ||
test_target: "src/*.test.ts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { stat } from "./stat/mod.ts"; | ||
export { stat } from "./src/stat.ts"; | ||
export { exists } from "./src/exists.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { assertEquals } from "@std/assert"; | ||
import { test } from "@cross/test"; | ||
|
||
import { exists } from "./exists.ts"; | ||
|
||
test("exists returns true on existing file", async () => { | ||
const result = await exists("./mod.ts"); | ||
assertEquals(result, true); | ||
}); | ||
|
||
test("exists returns false on non-existant file", async () => { | ||
const result = await exists("./mod-nonexistant.ts"); | ||
assertEquals(result, false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NotFoundError, stat } from "./stat.ts"; | ||
export async function exists(path: string): Promise<boolean> { | ||
try { | ||
await stat(path); | ||
return true; | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return false; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { assertEquals } from "@std/assert"; | ||
import { test } from "@cross/test"; | ||
|
||
import { isDir, isFile } from "./is.ts"; | ||
|
||
test("isFile returns true on existing file", async () => { | ||
const result = await isFile("./mod.ts"); | ||
assertEquals(result, true); | ||
}); | ||
|
||
test("isFile returns false on non-existiantfile", async () => { | ||
const result = await isFile("./mod-nonexistant.ts"); | ||
assertEquals(result, false); | ||
}); | ||
|
||
test("isDir returns false on existing file", async () => { | ||
const result = await isDir("./mod.ts"); | ||
assertEquals(result, false); | ||
}); | ||
|
||
test("isFile returns false on existing dir", async () => { | ||
const result = await isFile("./src"); | ||
assertEquals(result, false); | ||
}); | ||
|
||
test("isDir returns true on existing dir", async () => { | ||
const result = await isDir("./src"); | ||
assertEquals(result, true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { NotFoundError, stat } from "./stat.ts"; | ||
export async function isDir(path: string) { | ||
try { | ||
const result = await stat(path); | ||
return result.isDirectory; | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return false; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} | ||
export async function isFile(path: string) { | ||
try { | ||
const result = await stat(path); | ||
return result.isFile; | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return false; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} | ||
export async function isSymlink(path: string) { | ||
try { | ||
const result = await stat(path); | ||
return result.isSymlink; | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return false; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters