* Synchronously appends data to a file. * @param {string | Buffer | URL | number} path * @param {string | Buffer} data * @param {{ * encoding?: string | null; * mode?: number; * flag?: string; * } | string} [options] * @returns {void}
(path, data, options)
| 2994 | * @returns {void} |
| 2995 | */ |
| 2996 | function appendFileSync(path, data, options) { |
| 2997 | options = getOptions(options, { encoding: 'utf8', mode: 0o666, flag: 'a' }); |
| 2998 | parseFileMode(options.mode, 'mode', 0o666); |
| 2999 | |
| 3000 | const h = vfsState.handlers; |
| 3001 | if (h !== null) { |
| 3002 | const result = h.appendFileSync(path, data, options); |
| 3003 | if (result !== undefined) return; |
| 3004 | } |
| 3005 | |
| 3006 | // Don't make changes directly on options object |
| 3007 | options = copyObject(options); |
| 3008 | |
| 3009 | // Force append behavior when using a supplied file descriptor |
| 3010 | if (!options.flag || isFd(path)) |
| 3011 | options.flag = 'a'; |
| 3012 | |
| 3013 | fs.writeFileSync(path, data, options); |
| 3014 | } |
| 3015 | |
| 3016 | /** |
| 3017 | * Watches for the changes on `filename`. |
no test coverage detected
searching dependent graphs…