MCPcopy
hub / github.com/serverless/serverless / writeFile

Function writeFile

packages/sf-core/src/utils/fs/index.js:70–85  ·  view source on GitHub ↗
(filePath, conts, options)

Source from the content-addressed store, hash-verified

68 * @returns A promise that resolves when the file is written.
69 */
70const writeFile = async (filePath, conts, options) => {
71 let contents = conts || ''
72
73 await fsp.mkdir(path.dirname(filePath), { recursive: true })
74
75 if (filePath.endsWith('.json') && typeof contents !== 'string') {
76 contents = JSON.stringify(contents, null, 2)
77 }
78
79 const isYamlFile = filePath.endsWith('.yaml') || filePath.endsWith('.yml')
80 if (isYamlFile && typeof contents !== 'string') {
81 contents = yaml.dump(contents)
82 }
83
84 await fsp.writeFile(filePath, contents, options || {})
85}
86
87/**
88 * Checks if the source is not a symbolic link.

Callers 15

writeInstancesToCSVFunction · 0.90
ensureOrgInConfigFileFunction · 0.90
ensureAppInConfigFileFunction · 0.90
commandSupportFunction · 0.90
saveMetaFunction · 0.90
write-file.test.jsFile · 0.90
renameYmlServiceFunction · 0.70

Calls 1

writeFileMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…