Merge pull request #43 from drshade/master

check whether the folder exists before attempting to create it, avoid…
This commit is contained in:
Ryan Haskell-Glatz 2020-05-21 14:00:35 -05:00 committed by GitHub
commit 7b40c81e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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' })