MCPcopy Create free account
hub / github.com/denoland/std / writeFileSync

Function writeFileSync

fs/unstable_write_file.ts:84–110  ·  view source on GitHub ↗
(
  path: string | URL,
  data: Uint8Array,
  options?: WriteFileOptions,
)

Source from the content-addressed store, hash-verified

82 * @param options Options to write files. See {@linkcode WriteFileOptions}.
83 */
84export function writeFileSync(
85 path: string | URL,
86 data: Uint8Array,
87 options?: WriteFileOptions,
88): void {
89 if (isDeno) {
90 Deno.writeFileSync(path, data, { ...options });
91 } else {
92 const {
93 append = false,
94 create = true,
95 createNew = false,
96 mode,
97 signal,
98 } = options ?? {};
99
100 const flag = getWriteFsFlag({ append, create, createNew });
101 try {
102 getNodeFs().writeFileSync(path, data, { flag, signal });
103 if (mode != null) {
104 getNodeFs().chmodSync(path, mode);
105 }
106 } catch (error) {
107 throw mapError(error);
108 }
109 }
110}

Calls 3

getWriteFsFlagFunction · 0.90
getNodeFsFunction · 0.90
mapErrorFunction · 0.90

Tested by

no test coverage detected