mirror of
https://github.com/ryannhg/elm-spa.git
synced 2024-11-22 01:32:43 +03:00
check whether the folder exists before attempting to create it, avoiding exception
This commit is contained in:
parent
7cd64f7337
commit
c49fda2951
@ -37,7 +37,7 @@ const listFiles = (dir) =>
|
||||
[])
|
||||
|
||||
const ensureDirectory = (dir) =>
|
||||
fs.mkdirSync(dir, { recursive: true })
|
||||
fs.existsSync(dir) || fs.mkdirSync(dir, { recursive: true })
|
||||
|
||||
const saveToFolder = (prefix) => ({ filepath, content }) =>
|
||||
fs.writeFileSync(path.join(prefix, filepath), content, { encoding: 'utf8' })
|
||||
|
Loading…
Reference in New Issue
Block a user