From d0d731e27103283f0ba2c8855e6a0e647ed37eff Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 25 Aug 2021 21:12:30 +0800 Subject: [PATCH] doc: add descriptions about when `options.mode` is ignored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/39881 Fixes: https://github.com/nodejs/node/issues/39859 Reviewed-By: Tobias Nießen Reviewed-By: Darshan Sen Reviewed-By: James M Snell Reviewed-By: Anto Aravinth --- doc/api/fs.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index d3997ccfba4f72..396f80afbad146 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -613,6 +613,9 @@ exist. `data` can be a string or a {Buffer}. If `options` is a string, then it specifies the `encoding`. +The `mode` option only affects the newly created file. See [`fs.open()`][] +for more details. + The `path` may be specified as a {FileHandle} that has been opened for appending (using `fsPromises.open()`). @@ -1283,6 +1286,9 @@ The `encoding` option is ignored if `data` is a buffer. If `options` is a string, then it specifies the encoding. +The `mode` option only affects the newly created file. See [`fs.open()`][] +for more details. + Any specified {FileHandle} has to support writing. It is unsafe to use `fsPromises.writeFile()` multiple times on the same file @@ -1548,6 +1554,9 @@ changes: Asynchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a {Buffer}. +The `mode` option only affects the newly created file. See [`fs.open()`][] +for more details. + ```mjs import { appendFile } from 'fs'; @@ -3915,6 +3924,9 @@ a file descriptor. The `encoding` option is ignored if `data` is a buffer. +The `mode` option only affects the newly created file. See [`fs.open()`][] +for more details. + If `data` is a plain object, it must have an own (not inherited) `toString` function property. @@ -4086,6 +4098,9 @@ changes: Synchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a {Buffer}. +The `mode` option only affects the newly created file. See [`fs.open()`][] +for more details. + ```mjs import { appendFileSync } from 'fs'; @@ -4999,6 +5014,9 @@ Returns `undefined`. If `data` is a plain object, it must have an own (not inherited) `toString` function property. +The `mode` option only affects the newly created file. See [`fs.open()`][] +for more details. + For detailed information, see the documentation of the asynchronous version of this API: [`fs.writeFile()`][].