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 |
|
13 | When 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 |
|
15 | Using `@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 |
|
17 | This 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 |
|
19 | If 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
|
30 | npm install @vscode-utility/fs-browserify
|
31 | ```
|
32 |
|
33 | **yarn**
|
34 |
|
35 | ```sh
|
36 | yarn add @vscode-utility/fs-browserify
|
37 | ```
|
38 |
|
39 | **pnpm**
|
40 |
|
41 | ```sh
|
42 | pnpm add @vscode-utility/fs-browserify
|
43 | ```
|
44 |
|
45 | ## Usage
|
46 |
|
47 | ```typescript
|
48 | import { fs } from '@vscode-utility/fs-browserify';
|
49 |
|
50 | // Retrieve file metadata
|
51 | await fs.statAsync(path);
|
52 |
|
53 | // Retrieve all directory entries
|
54 | await fs.readDirectoryAsync(path);
|
55 |
|
56 | // Create a new directory
|
57 | await fs.createDirectoryAsync(path);
|
58 |
|
59 | // Read the full content of a file
|
60 | await fs.readFileAsync(path, options);
|
61 |
|
62 | // Append the provided data to a file
|
63 | await fs.appendFileAsync(path, content);
|
64 |
|
65 | // Write data to a file and replace its full contents
|
66 | await fs.writeFileAsync(path, content);
|
67 |
|
68 | // Delete a file
|
69 | await fs.deleteAsync(path, options);
|
70 |
|
71 | // Rename a file or folder
|
72 | await fs.renameAsync(source, target, options);
|
73 |
|
74 | // Copy files or folders
|
75 | await fs.copyAsync(source, target, options);
|
76 |
|
77 | // Check if a given path exists or not in the file system
|
78 | await fs.existAsync(source);
|
79 |
|
80 | // Truncates the file to change the size of the file i.e either increase or decrease the file size
|
81 | await fs.existAsync(path, length);
|
82 |
|
83 | // Check the permissions of a given file
|
84 | fs.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 |
|
120 | If you discover a bug, or have a suggestion for a feature request, please
|
121 | submit an [issue](https://github.com/nguyenngoclongdev/vscode-fs-browserify/issues).
|
122 |
|
123 | ## LICENSE
|
124 |
|
125 | This extension is licensed under the [MIT License](LICENSE)
|