vscode-fs 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -26,6 +26,16 @@ let FileType = /* @__PURE__ */ function(FileType) {
26
26
  FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
27
27
  return FileType;
28
28
  }({});
29
+ /**
30
+ * The flags to use for the file.
31
+ */
32
+ let WriteableFlags = /* @__PURE__ */ function(WriteableFlags) {
33
+ /**
34
+ * Append to the file.
35
+ */
36
+ WriteableFlags["Append"] = "a";
37
+ return WriteableFlags;
38
+ }({});
29
39
  let FileSystemError;
30
40
  (function(_FileSystemError) {
31
41
  function isFileSystemError(error) {
@@ -247,7 +257,7 @@ async function createNodeFileSystem() {
247
257
  writeFile: (uri, content) => wrap(() => fs.promises.writeFile(uri.fsPath, content)),
248
258
  delete: (uri, options) => wrap(async () => {
249
259
  if (options?.useTrash) await trash(uri.fsPath);
250
- else await fs.promises.rm(uri.fsPath, { recursive: options?.recursive });
260
+ else await fs.promises.rm(uri.fsPath, { recursive: options?.recursive ?? false });
251
261
  }),
252
262
  rename: (source, target, options) => wrap(async () => {
253
263
  if (options?.overwrite === false) await ensureTargetNotExists(target.fsPath);
@@ -339,8 +349,12 @@ async function createNodeFileSystem() {
339
349
  });
340
350
  });
341
351
  },
342
- createWritableStream: async (uri) => {
343
- const writableStream = fs.createWriteStream(uri.fsPath);
352
+ createWritableStream: async (uri, options) => {
353
+ const writableStream = fs.createWriteStream(uri.fsPath, {
354
+ ...options,
355
+ encoding: options?.encoding,
356
+ flags: options?.flags
357
+ });
344
358
  return stream.Writable.toWeb(writableStream);
345
359
  },
346
360
  createReadableStream: async (uri) => {
@@ -396,6 +410,7 @@ Object.defineProperty(exports, 'FileSystemError', {
396
410
  exports.FileSystemProviderErrorCode = FileSystemProviderErrorCode;
397
411
  exports.FileType = FileType;
398
412
  exports.RelativePattern = RelativePattern;
413
+ exports.WriteableFlags = WriteableFlags;
399
414
  exports.createFileSystemError = createFileSystemError;
400
415
  exports.createNodeFileSystem = createNodeFileSystem;
401
416
  exports.toFileSystemError = toFileSystemError;
package/dist/index.d.cts CHANGED
@@ -238,7 +238,20 @@ interface FileSystem {
238
238
  * @param uri The uri of the file to write to.
239
239
  * @returns A writer for the file.
240
240
  */
241
- createWritableStream(uri: URI): Promise<WritableStream<Uint8Array>>;
241
+ createWritableStream(uri: URI, options?: {
242
+ /**
243
+ * The encoding to use for the file.
244
+ */
245
+ readonly encoding?: NodeJS.BufferEncoding | (string & {});
246
+ /**
247
+ * The flag to use for the file.
248
+ */
249
+ readonly flags?: WriteableFlags | (string & {});
250
+ /**
251
+ * Additional options.
252
+ */
253
+ readonly [key: string]: unknown;
254
+ }): Promise<WritableStream<Uint8Array>>;
242
255
  /**
243
256
  * Create a readable stream for a file.
244
257
  *
@@ -247,6 +260,15 @@ interface FileSystem {
247
260
  */
248
261
  createReadableStream(uri: URI): Promise<ReadableStream<Uint8Array>>;
249
262
  }
263
+ /**
264
+ * The flags to use for the file.
265
+ */
266
+ declare enum WriteableFlags {
267
+ /**
268
+ * Append to the file.
269
+ */
270
+ Append = "a"
271
+ }
250
272
  interface Disposable {
251
273
  /** Dispose resources. */
252
274
  dispose(): unknown;
@@ -415,4 +437,4 @@ declare function toFileSystemError(error: NodeJS.ErrnoException): FileSystemErro
415
437
  //#region src/node.d.ts
416
438
  declare function createNodeFileSystem(): Promise<FileSystem>;
417
439
  //#endregion
418
- export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, createFileSystemError, createNodeFileSystem, toFileSystemError };
440
+ export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, WriteableFlags, createFileSystemError, createNodeFileSystem, toFileSystemError };
package/dist/index.d.mts CHANGED
@@ -238,7 +238,20 @@ interface FileSystem {
238
238
  * @param uri The uri of the file to write to.
239
239
  * @returns A writer for the file.
240
240
  */
241
- createWritableStream(uri: URI): Promise<WritableStream<Uint8Array>>;
241
+ createWritableStream(uri: URI, options?: {
242
+ /**
243
+ * The encoding to use for the file.
244
+ */
245
+ readonly encoding?: NodeJS.BufferEncoding | (string & {});
246
+ /**
247
+ * The flag to use for the file.
248
+ */
249
+ readonly flags?: WriteableFlags | (string & {});
250
+ /**
251
+ * Additional options.
252
+ */
253
+ readonly [key: string]: unknown;
254
+ }): Promise<WritableStream<Uint8Array>>;
242
255
  /**
243
256
  * Create a readable stream for a file.
244
257
  *
@@ -247,6 +260,15 @@ interface FileSystem {
247
260
  */
248
261
  createReadableStream(uri: URI): Promise<ReadableStream<Uint8Array>>;
249
262
  }
263
+ /**
264
+ * The flags to use for the file.
265
+ */
266
+ declare enum WriteableFlags {
267
+ /**
268
+ * Append to the file.
269
+ */
270
+ Append = "a"
271
+ }
250
272
  interface Disposable {
251
273
  /** Dispose resources. */
252
274
  dispose(): unknown;
@@ -415,4 +437,4 @@ declare function toFileSystemError(error: NodeJS.ErrnoException): FileSystemErro
415
437
  //#region src/node.d.ts
416
438
  declare function createNodeFileSystem(): Promise<FileSystem>;
417
439
  //#endregion
418
- export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, createFileSystemError, createNodeFileSystem, toFileSystemError };
440
+ export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, WriteableFlags, createFileSystemError, createNodeFileSystem, toFileSystemError };
package/dist/index.mjs CHANGED
@@ -25,6 +25,16 @@ let FileType = /* @__PURE__ */ function(FileType) {
25
25
  FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
26
26
  return FileType;
27
27
  }({});
28
+ /**
29
+ * The flags to use for the file.
30
+ */
31
+ let WriteableFlags = /* @__PURE__ */ function(WriteableFlags) {
32
+ /**
33
+ * Append to the file.
34
+ */
35
+ WriteableFlags["Append"] = "a";
36
+ return WriteableFlags;
37
+ }({});
28
38
  let FileSystemError;
29
39
  (function(_FileSystemError) {
30
40
  function isFileSystemError(error) {
@@ -246,7 +256,7 @@ async function createNodeFileSystem() {
246
256
  writeFile: (uri, content) => wrap(() => fs.promises.writeFile(uri.fsPath, content)),
247
257
  delete: (uri, options) => wrap(async () => {
248
258
  if (options?.useTrash) await trash(uri.fsPath);
249
- else await fs.promises.rm(uri.fsPath, { recursive: options?.recursive });
259
+ else await fs.promises.rm(uri.fsPath, { recursive: options?.recursive ?? false });
250
260
  }),
251
261
  rename: (source, target, options) => wrap(async () => {
252
262
  if (options?.overwrite === false) await ensureTargetNotExists(target.fsPath);
@@ -338,8 +348,12 @@ async function createNodeFileSystem() {
338
348
  });
339
349
  });
340
350
  },
341
- createWritableStream: async (uri) => {
342
- const writableStream = fs.createWriteStream(uri.fsPath);
351
+ createWritableStream: async (uri, options) => {
352
+ const writableStream = fs.createWriteStream(uri.fsPath, {
353
+ ...options,
354
+ encoding: options?.encoding,
355
+ flags: options?.flags
356
+ });
343
357
  return stream.Writable.toWeb(writableStream);
344
358
  },
345
359
  createReadableStream: async (uri) => {
@@ -386,4 +400,4 @@ var NodeFileSystemWatcherImpl = class {
386
400
  };
387
401
 
388
402
  //#endregion
389
- export { FileSystemError, FileSystemProviderErrorCode, FileType, RelativePattern, createFileSystemError, createNodeFileSystem, toFileSystemError };
403
+ export { FileSystemError, FileSystemProviderErrorCode, FileType, RelativePattern, WriteableFlags, createFileSystemError, createNodeFileSystem, toFileSystemError };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vscode-fs",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "description": "VSCode like simple、serializable and cross-platform file system utilities.",
6
6
  "author": "Naily Zero <zero@naily.cc> (https://naily.cc)",
7
7
  "license": "MIT",