file exists for new script

This commit is contained in:
Ivan Dimitrov 2023-11-11 19:56:51 +02:00
parent 884b72a257
commit 53907ea9e1

7
new.ts
View File

@ -24,5 +24,10 @@ draft: true
---
`
fs.writeFileSync(`${baseDir}${path}.md`, meta(), {flag: "w+"})
const filePath = `${baseDir}${path}.md`
if (fs.existsSync(filePath)) {
throw new Error("File already exists!")
}
fs.writeFileSync(filePath, meta(), { flag: "w+" })