Skip to content

Commit

Permalink
Release 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Mar 27, 2024
1 parent 3ca925b commit 25b692d
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
uses: cross-org/workflows/.github/workflows/node-ci.yml@main
with:
jsr_dependencies: "@cross/test @std/assert @cross/runtime"
test_target: "src/*.test.ts"
test_target: "**/*.test.ts"
67 changes: 19 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,26 @@
# @cross/fs

**Work in progress** Cross Runtime filesystem operations for JavaScript and
TypeScript.
A cross-runtime utility library collecting best practices around filesystem
operations for JavaScript and TypeScript. Available for Node, Deno Bun and
Browser at [jsr.io/@cross/fs](https://jsr.io/@cross/fs).

Available for Node, Deno Bun and Browser at
[jsr.io/@cross/fs](https://jsr.io/@cross/fs), works seamlessly with both
JavaScript and TypeScript.

For cross rutime path operations, [jsr.io/@std/path](https://jsr.io/@std/path)
For cross rutime _path_ operations, [jsr.io/@std/path](https://jsr.io/@std/path)
will cover most scenarios, this library focuses on the file system operations.

## Coverage

| Method | Deno | Node | Bun | Browser (LocalStorage) |
| --------- | ---- | ---- | --- | ---------------------- |
| stat | X | X | X | |
| exists | X | X | X | |
| isDir | X | X | X | |
| isFile | X | X | X | |
| isSymlink | X | X | X | |
| ... | | | | |

## Contribution guide

## Deno

```bash
# Run an example using Deno
deno run -A examples/stat.ts
```
**Note:** This is work in progress.

## Bun

```bash
# Install deps locally
bun jsr add @cross/runtime
```

```bash
# Run an example using Bun
bun run examples/stat.ts
```

## Node

````bash
# Install deps locally
npx jsr add @cross/runtime
``
## Coverage

```bash
# Run an example using tsx in Node
npx tsx examples/stat.ts
````
| Module | Method | Deno | Node | Bun | Browser (LocalStorage) |
| ------ | ---------- | ---- | ---- | --- | ---------------------- |
| stat | stat | X | X | X | |
| stat | exists | X | X | X | |
| stat | isDir | X | X | X | |
| stat | isFile | X | X | X | |
| stat | isSymlink | X | X | X | |
| ------ | ---------- | ---- | ---- | --- | ---------------------- |
| io | readFile | X | X | X | |
| io | writeFile | X | X | X | |
| ------ | ---------- | ---- | ---- | --- | ---------------------- |
| ops | unlink | X | X | X | |
| ------ | ---------- | ---- | ---- | --- | ---------------------- |
7 changes: 6 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "@cross/fs",
"version": "0.0.3",
"exports": "./mod.ts",
"exports": {
".": "./mod.ts",
"./stat": "./stat/mod.ts",
"./io": "./io/mod.ts",
"./ops": "./ops/mod.ts"
},
"imports": {
"@cross/runtime": "jsr:@cross/runtime@^1.0.0",
"@cross/test": "jsr:@cross/test@^0.0.9",
Expand Down
3 changes: 0 additions & 3 deletions examples/stat.ts

This file was deleted.

5 changes: 3 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { stat } from "./src/stat.ts";
export { exists } from "./src/exists.ts";
export * from "./src/stat/mod.ts";
export * from "./src/io/mod.ts";
export * from "./src/ops/mod.ts";
2 changes: 2 additions & 0 deletions src/io/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./read.ts";
export * from "./write.ts";
1 change: 1 addition & 0 deletions src/io/read.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { readFile } from "node:fs/promises";
1 change: 1 addition & 0 deletions src/io/write.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { writeFile } from "node:fs/promises";
1 change: 1 addition & 0 deletions src/ops/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./unlink.ts";
1 change: 1 addition & 0 deletions src/ops/unlink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { unlink } from "node:fs/promises";
File renamed without changes.
2 changes: 1 addition & 1 deletion src/exists.ts → src/stat/exists.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NotFoundError, stat } from "./stat.ts";
import { NotFoundError, stat } from "./mod.ts";
export async function exists(path: string): Promise<boolean> {
try {
await stat(path);
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/is.ts → src/stat/is.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NotFoundError, stat } from "./stat.ts";
import { NotFoundError, stat } from "./mod.ts";

export async function isDir(path: string) {
try {
const result = await stat(path);
Expand Down
2 changes: 2 additions & 0 deletions src/stat.ts → src/stat/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,5 @@ function mapDenoStats(stats: Deno.FileInfo): StatResult {
}

export { statWrap as stat };
export * from "./is.ts";
export * from "./exists.ts";

0 comments on commit 25b692d

Please sign in to comment.