From 22290ab4fe2e66ea2c9f03ba4daee96243d919dc Mon Sep 17 00:00:00 2001 From: James P Date: Fri, 5 Apr 2024 13:45:22 -0500 Subject: [PATCH] Upgraded to latest core --- .github/workflows/ci.yaml | 20 +++++++++++++------- .github/workflows/release.yaml | 1 + package-lock.json | 8 ++++---- package.json | 2 +- src/FileSystemAccess.ts | 18 +++++++++--------- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b00dff..ee4b642 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,9 +4,9 @@ on: push: branches: - main - - master workflow_dispatch: workflow_call: + pull_request: jobs: ci: @@ -39,7 +39,6 @@ jobs: - name: Linting run: npm run lint - # Once unit tests are working #- name: Unit tests # run: npm run test @@ -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 @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 733bec4..c13b2b6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,6 +10,7 @@ jobs: permissions: contents: write id-token: write + pages: write release: runs-on: ubuntu-latest needs: ci diff --git a/package-lock.json b/package-lock.json index bf62fb4..ad66132 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "node": ">= 18" }, "peerDependencies": { - "@zenfs/core": "^0.5.3" + "@zenfs/core": "^0.5.5" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -776,9 +776,9 @@ "dev": true }, "node_modules/@zenfs/core": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/@zenfs/core/-/core-0.5.3.tgz", - "integrity": "sha512-Nu5T5ww7m+wAi7LVTUzWw2WCfVRTgXcL6fglHAxmZzhYYUwxQlOLkgv+p8TLJICgI2Jc2egUPHPof/xRkB6VVA==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@zenfs/core/-/core-0.5.5.tgz", + "integrity": "sha512-v0IrVfGXKBwrbk79kb+4dqB4Vf9Qk6mjLPmngs370K1BSbcc8cyp69iw7K10oHq2FcLNX+mgCEuxY3sTGQ6X+A==", "peer": true, "dependencies": { "@types/node": "^14.0.0", diff --git a/package.json b/package.json index 6cc8a25..04074f2 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,6 @@ "typescript": "5.2.2" }, "peerDependencies": { - "@zenfs/core": "^0.5.3" + "@zenfs/core": "^0.5.5" } } diff --git a/src/FileSystemAccess.ts b/src/FileSystemAccess.ts index aebcf03..633d3b7 100644 --- a/src/FileSystemAccess.ts +++ b/src/FileSystemAccess.ts @@ -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; @@ -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); } } @@ -133,7 +133,7 @@ export class FileSystemAccessFS extends Async(FileSystem) { public async stat(path: string): Promise { 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 }); @@ -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); } } } @@ -176,7 +176,7 @@ export class FileSystemAccessFS extends Async(FileSystem) { public async mkdir(path: string): Promise { 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)); @@ -188,7 +188,7 @@ export class FileSystemAccessFS extends Async(FileSystem) { public async readdir(path: string): Promise { 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()) { @@ -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); } } };