Skip to content

Commit

Permalink
Hotfix: update fetch method docs in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
StarLederer committed Mar 26, 2022
1 parent 62365e9 commit 20138f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,33 +151,22 @@ await fs.rm('path/to/somewhere', { recursive: true });
This is a more direct way to interact with the relay server, however, it is inconvenient, error-prone and there is no type checking. While this method is documented, it is not recommended to use and the docs for it might get removed. The API for network requests might also change a lot, unlike the abstraction API that will always act as much like node fs as possible.
To read a file or directory
```ts
await fetch(`http://localhost:7070/path/to/somewhere`);
// if file found, returns {type: 'file', data: RESULT OF fs.readFile(.../path/to/somewhere)}
// if directory found, returns {type: 'dir', items: ['child1', 'child2'...]}
```
To read a file set the **command** querry to **readfile**
To read a file
```ts
await fetch(`http://localhost:7070/path/to/somewhere?command=readfile`);
// if file found, returns {type: 'file', data: RESULT OF fs.readFile(.../path/to/somewhere)}
await fetch(`http://localhost:7070/path/to/somewhere?command=readFile`);
```
To read a directory set the **command** querry to **readdir**
To read a directory
```ts
await fetch(`http://localhost:7070/path/to/somewhere?command=readdir`);
// if directory found, returns {type: 'dir', items: ['child1', 'child2'...]}
```
To execute fs.stat set the **command** querry to **stat**
To execute fs.stat
```ts
await fetch(`http://localhost:7070/path/to/somewhere?command=stat`);
// if file or directory found returns {type: 'stats', stats: {...RESULTS_OF fs.stat(), dir: RESULT OF fs.stat().isDirectory()}}
```
To write a file
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-fs",
"version": "0.4.3",
"version": "0.4.4",
"description": "Interact with fs by fetching requests from a local API",
"main": "./lib/plugin/index.cjs",
"module": "./lib/plugin/index.js",
Expand Down

0 comments on commit 20138f4

Please sign in to comment.