[njs] Types: fixed description for fs.mkdir() and fs.rmdir() methods.

Dmitry Volyntsev xeioex at nginx.com
Mon Nov 7 22:23:46 UTC 2022


details:   https://hg.nginx.org/njs/rev/3a9415ae3330
branches:  
changeset: 1991:3a9415ae3330
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon Nov 07 14:22:41 2022 -0800
description:
Types: fixed description for fs.mkdir() and fs.rmdir() methods.

This closes #600 issue on Github.

diffstat:

 test/ts/test.ts        |   6 ++++++
 ts/njs_modules/fs.d.ts |  22 ++++++++++++++++------
 2 files changed, 22 insertions(+), 6 deletions(-)

diffs (73 lines):

diff -r fa59bcc82142 -r 3a9415ae3330 test/ts/test.ts
--- a/test/ts/test.ts	Mon Nov 07 14:22:41 2022 -0800
+++ b/test/ts/test.ts	Mon Nov 07 14:22:41 2022 -0800
@@ -131,6 +131,12 @@ async function fs_module() {
     buffer[1] += 2;
     fs.writeSync(fd, buffer, 0, 16, 4);
     fs.closeSync(fd);
+
+    fs.mkdirSync('a/b/c', {recursive: true});
+    await fs.promises.mkdir('d/e/f', {recursive: false});
+
+    fs.rmdirSync('a/b/c', {recursive: true});
+    await fs.promises.rmdir('d/e/f', {recursive: false});
 }
 
 function qs_module(str: NjsByteString) {
diff -r fa59bcc82142 -r 3a9415ae3330 ts/njs_modules/fs.d.ts
--- a/ts/njs_modules/fs.d.ts	Mon Nov 07 14:22:41 2022 -0800
+++ b/ts/njs_modules/fs.d.ts	Mon Nov 07 14:22:41 2022 -0800
@@ -288,9 +288,12 @@ declare module "fs" {
          *
          * @since 0.4.2
          * @param path A path to a file.
-         * @param options The file mode (or an object specifying the file mode). Defaults to `0o777`.
+         * @param options A number specifying file mode, defaults to `0o777`.
+         * @param options An object with the following optional keys:
+         *   - `mode` - A number specifying file mode, defaults to `0o777`.
+         *   - `recursive` -  If true, perform a recursive directory creation, defaults to `false`.
          */
-        mkdir(path: PathLike, options?: { mode?: number } | number): Promise<void>;
+        mkdir(path: PathLike, options?: { mode?: number; recursive?: boolean; } | number): Promise<void>;
 
         /**
          * Asynchronously reads the contents of a directory at the specified `path`.
@@ -344,8 +347,10 @@ declare module "fs" {
          *
          * @since 0.4.2
          * @param path A path to a file.
+         * @param options An object with the following optional keys:
+         *   - `recursive` -  If true, perform a recursive directory removal, defaults to `false`.
          */
-        rmdir(path: PathLike): Promise<void>;
+        rmdir(path: PathLike, options?: { recursive?: boolean; }): Promise<void>;
 
         /**
          * Asynchronously retrieves `fs.Stats` object for the specified `path`.
@@ -537,9 +542,12 @@ declare module "fs" {
          *
          * @since 0.4.2
          * @param path A path to a file.
-         * @param options The file mode (or an object specifying the file mode). Defaults to `0o777`.
+         * @param options A number specifying file mode. defaults to `0o777`.
+         * @param options An object with the following optional keys:
+         *   - `mode` - A number specifying file mode, defaults to `0o777`.
+         *   - `recursive` -  If true, perform a recursive directory creation, defaults to `false`.
          */
-        mkdirSync(path: PathLike, options?: { mode?: number } | number): void;
+        mkdirSync(path: PathLike, options?: { mode?: number; recursive?: boolean; } | number): void;
 
         /**
          * Synchronously opens a file specified in the `path`.
@@ -635,8 +643,10 @@ declare module "fs" {
          *
          * @since 0.4.2
          * @param path A path to a file.
+         * @param options An object with the following optional keys:
+         *   - `recursive` -  If true, perform a recursive directory removal, defaults to `false`.
          */
-        rmdirSync(path: PathLike): void;
+        rmdirSync(path: PathLike, options?: { recursive?: boolean; }): void;
 
         /**
          * Synchronously retrieves `fs.Stats` object for the specified path.



More information about the nginx-devel mailing list