MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / createHeaderFile

Function createHeaderFile

tools/js/utils/create-header-file.js:36–58  ·  view source on GitHub ↗
(content, filePath)

Source from the content-addressed store, hash-verified

34`
35
36const createHeaderFile = async (content, filePath) => {
37 const dir = path.dirname(filePath)
38 await fs.ensureDir(dir)
39 const fileContent = `${header}${content}`
40 const fileExists = await fs.pathExists(filePath)
41 if (fileExists) {
42 const { overwrite } = await inquirer.prompt([
43 {
44 type: 'confirm',
45 name: 'overwrite',
46 message: `File ${filePath} already exists. Overwrite?`,
47 default: false,
48 },
49 ])
50 if (!overwrite) {
51 console.log('File not created.')
52 return
53 }
54 }
55
56 await fs.writeFile(filePath, fileContent)
57 console.log(`File created: ${filePath}`)
58}
59
60export default createHeaderFile

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected