MCPcopy Index your code
hub / github.com/nodejs/node / appendFileSync

Function appendFileSync

lib/fs.js:2996–3014  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

2994 * @returns {void}
2995 */
2996function 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`.

Callers 2

restartFunction · 0.85

Calls 5

parseFileModeFunction · 0.85
copyObjectFunction · 0.85
getOptionsFunction · 0.50
appendFileSyncMethod · 0.45
writeFileSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…