Skip to content

Commit

Permalink
Upgraded to latest core
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Apr 5, 2024
1 parent 1279d52 commit 22290ab
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches:
- main
- master
workflow_dispatch:
workflow_call:
pull_request:

jobs:
ci:
Expand Down Expand Up @@ -39,7 +39,6 @@ jobs:
- name: Linting
run: npm run lint

# Once unit tests are working
#- name: Unit tests
# run: npm run test

Expand All @@ -52,6 +51,10 @@ jobs:
permissions:
contents: write
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -67,9 +70,12 @@ jobs:
- name: Build docs
run: npm run build:docs

- name: Deploy docs
uses: peaceiris/actions-gh-pages@v3
- name: Upload docs artifact
uses: actions/upload-pages-artifact@v3
if: github.event_name != 'pull_request'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
publish_branch: docs
path: ./docs
- name: 'Deploy docs'
id: deploy
if: github.event_name != 'pull_request'
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
permissions:
contents: write
id-token: write
pages: write
release:
runs-on: ubuntu-latest
needs: ci
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@zenfs/core": "^0.5.3"
"@zenfs/core": "^0.5.5"
}
}
18 changes: 9 additions & 9 deletions src/FileSystemAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export interface FileSystemAccessOptions {
handle: FileSystemDirectoryHandle;
}

const handleError = (path = '', error: Error) => {
const handleError = (path = '', syscall: string, error: Error) => {
if (error.name === 'NotFoundError') {
throw ApiError.ENOENT(path);
throw ApiError.With('ENOENT', path, syscall);
}

throw error as ApiError;
Expand Down Expand Up @@ -109,7 +109,7 @@ export class FileSystemAccessFS extends Async(FileSystem) {
writable.close();
await this.unlink(oldPath);
} catch (err) {
handleError(oldPath, err);
handleError(oldPath, 'rename', err);
}
}

Expand All @@ -133,7 +133,7 @@ export class FileSystemAccessFS extends Async(FileSystem) {
public async stat(path: string): Promise<Stats> {
const handle = await this.getHandle(path);
if (!handle) {
throw ApiError.OnPath(ErrorCode.ENOENT, path);
throw ApiError.With('ENOENT', path, 'stat');
}
if (handle instanceof FileSystemDirectoryHandle) {
return new Stats({ mode: 0o777 | FileType.DIRECTORY, size: 4096 });
Expand All @@ -160,7 +160,7 @@ export class FileSystemAccessFS extends Async(FileSystem) {
try {
await handle.removeEntry(basename(path), { recursive: true });
} catch (e) {
handleError(path, e);
handleError(path, 'unlink', e);
}
}
}
Expand All @@ -176,7 +176,7 @@ export class FileSystemAccessFS extends Async(FileSystem) {
public async mkdir(path: string): Promise<void> {
const existingHandle = await this.getHandle(path);
if (existingHandle) {
throw ApiError.EEXIST(path);
throw ApiError.With('EEXIST', path, 'mkdir');
}

const handle = await this.getHandle(dirname(path));
Expand All @@ -188,7 +188,7 @@ export class FileSystemAccessFS extends Async(FileSystem) {
public async readdir(path: string): Promise<string[]> {
const handle = await this.getHandle(path);
if (!(handle instanceof FileSystemDirectoryHandle)) {
throw ApiError.ENOTDIR(path);
throw ApiError.With('ENOTDIR', path, 'readdir');
}
const _keys: string[] = [];
for await (const key of handle.keys()) {
Expand Down Expand Up @@ -225,12 +225,12 @@ export class FileSystemAccessFS extends Async(FileSystem) {
try {
return continueWalk(await handle.getFileHandle(pathPart));
} catch (err) {
handleError(walkingPath, err);
handleError(walkingPath, 'getHandle', err);
}
} else if (error.message === 'Name is not allowed.') {
throw new ApiError(ErrorCode.ENOENT, error.message, walkingPath);
} else {
handleError(walkingPath, error);
handleError(walkingPath, 'getHandle', error);
}
}
};
Expand Down

0 comments on commit 22290ab

Please sign in to comment.