UNPKG

5.94 kBMarkdownView Raw
1[![CI](https://github.com/nguyenngoclongdev/vscode-fs-browserify/actions/workflows/ci.yml/badge.svg)](https://github.com/nguyenngoclongdev/vscode-fs-browserify/actions/workflows/ci.yml)
2[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/nguyenngoclongdev/vscode-fs-browserify/)
3
4[![npm version](https://img.shields.io/npm/v/@vscode-utility/fs-browserify.svg?style=flat-square)](https://www.npmjs.org/package/@vscode-utility/fs-browserify)
5[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/nguyenngoclongdev/vscode-fs-browserify)
6[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=@vscode-utility/fs-browserify&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=@vscode-utility/fs-browserify)
7[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@vscode-utility/fs-browserify?style=flat-square)](https://bundlephobia.com/package/@vscode-utility/fs-browserify@latest)
8[![npm downloads](https://img.shields.io/npm/dt/@vscode-utility/fs-browserify.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@vscode-utility/fs-browserify)
9[![Known Vulnerabilities](https://snyk.io/test/npm/@vscode-utility/fs-browserify/badge.svg)](https://snyk.io/test/npm/@vscode-utility/fs-browserify)
10
11# @vscode-utility/fs-browserify
12
13When developing vscode extensions, it is essential to ensure compatibility between the desktop and web versions of vscode (https://vscode.dev or https://github.dev).
14
15Using `@vscode-utility/fs-browserify`, you can access and manipulate files stored locally or remotely, making it easier to develop vscode extensions that work seamlessly on both the desktop and web versions of vscode.
16
17This library utilizes a portion of the [File System](https://code.visualstudio.com/api/references/vscode-api#FileSystem) provided by the [VS Code API](https://code.visualstudio.com/api/references/vscode-api).
18
19If you find this package useful for your projects, please consider supporting me by [Patreon](https://patreon.com/nguyenngoclong), [KO-FI](https://ko-fi.com/nguyenngoclong) or [Paypal](http://paypal.com/paypalme/longnguyenngoc). It's a great way to help me maintain and improve this tool in the future. Your support is truly appreciated!
20
21[![KO-FI](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/nguyenngoclong)
22[![Paypal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](http://paypal.com/paypalme/longnguyenngoc)
23[![Patreon](https://img.shields.io/badge/Patreon-F96854?style=for-the-badge&logo=patreon&logoColor=white)](https://patreon.com/nguyenngoclong)
24
25## Installation
26
27**npm**
28
29```sh
30npm install @vscode-utility/fs-browserify
31```
32
33**yarn**
34
35```sh
36yarn add @vscode-utility/fs-browserify
37```
38
39**pnpm**
40
41```sh
42pnpm add @vscode-utility/fs-browserify
43```
44
45## Usage
46
47```typescript
48import { fs } from '@vscode-utility/fs-browserify';
49
50// Retrieve file metadata
51await fs.statAsync(path);
52
53// Retrieve all directory entries
54await fs.readDirectoryAsync(path);
55
56// Create a new directory
57await fs.createDirectoryAsync(path);
58
59// Read the full content of a file
60await fs.readFileAsync(path, options);
61
62// Append the provided data to a file
63await fs.appendFileAsync(path, content);
64
65// Write data to a file and replace its full contents
66await fs.writeFileAsync(path, content);
67
68// Delete a file
69await fs.deleteAsync(path, options);
70
71// Rename a file or folder
72await fs.renameAsync(source, target, options);
73
74// Copy files or folders
75await fs.copyAsync(source, target, options);
76
77// Check if a given path exists or not in the file system
78await fs.existAsync(source);
79
80// Truncates the file to change the size of the file i.e either increase or decrease the file size
81await fs.existAsync(path, length);
82
83// Check the permissions of a given file
84fs.access(path);
85```
86
87## Compare functions
88
89| @vscode-utility/fs-browserify | fs (node) | fs (vscode api) |
90| ----------------------------- | ----------------- | ---------------------- |
91| fs.`statAsync`() | fs.`stat`() | fs.`stat`() |
92| fs.`readDirectoryAsync`() | fs.`readDir`() | fs.`readDirectory`() |
93| fs.`createDirectoryAsync`() | fs.`mkdir`() | fs.`createDirectory`() |
94| fs.`readFileAsync`() | fs.`readFile`() | fs.`readFile`() |
95| fs.`appendFileAsync`() | fs.`appendFile`() | <sub>undefined</sub> |
96| fs.`writeFileAsync`() | fs.`writeFile`() | fs.`writeFile`() |
97| fs.`deleteAsync`() | fs.`rmdir`() | fs.`delete`() |
98| fs.`renameAsync`() | fs.`rename`() | fs.`rename`() |
99| fs.`copyAsync`() | fs.`cp`() | fs.`copy`() |
100| fs.`existAsync`() | fs.`exist`() | <sub>undefined</sub> |
101| fs.`truncateAsync`() | fs.`truncate`() | <sub>undefined</sub> |
102| fs.`watch`() | fs.`watch`() | <sub>undefined</sub> |
103| fs.`access`() | fs.`access`() | <sub>undefined</sub> |
104
105- @vscode-utility/fs-browserify
106
107 - Provides seamless compatibility for both the desktop and web versions of VS Code
108 - Supports additional functions that are missing from the [File System API](https://code.visualstudio.com/api/references/vscode-api#FileSystem)
109
110- fs (node)
111
112 - Only works with the desktop version of VS Code
113
114- fs (vscode api)
115
116 - Missing some necessary functions for the File System
117
118## Feedback
119
120If you discover a bug, or have a suggestion for a feature request, please
121submit an [issue](https://github.com/nguyenngoclongdev/vscode-fs-browserify/issues).
122
123## LICENSE
124
125This extension is licensed under the [MIT License](LICENSE)