From 0a43f6bbec248c27319110b8d18384ecef9201bd Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Sun, 3 Sep 2017 14:12:10 +0200 Subject: [PATCH] Fix copy to website script to work if main-partial is missing. --- bin/copy-to-piskel-website.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/copy-to-piskel-website.js b/bin/copy-to-piskel-website.js index 8e15af9f..b279c88f 100644 --- a/bin/copy-to-piskel-website.js +++ b/bin/copy-to-piskel-website.js @@ -17,7 +17,16 @@ function onCopy(err) { console.log('Copied static files to piskel-website...'); let previousPartialPath = path.resolve(PISKELAPP_PATH, 'templates/editor/main-partial.html'); - fs.unlink(previousPartialPath, onDeletePreviousPartial); + fs.access(previousPartialPath, fs.constants.F_OK, function (err) { + if (err) { + // File does not exit, call next step directly. + console.error('Previous main partial doesn\'t exist yet.'); + onDeletePreviousPartial(); + } else { + // File exists, try to delete it before moving on. + fs.unlink(previousPartialPath, onDeletePreviousPartial); + } + }) } function onDeletePreviousPartial(err) {