From 854185ecd591197fb4dc3152b6788d1f6b9097bc Mon Sep 17 00:00:00 2001 From: Alexander Mays Date: Tue, 9 Feb 2016 07:02:57 -0500 Subject: [PATCH] Added error handling so the process stays alive whenever transpiling fails Signed-off-by: Alexander Mays --- bin/dev | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/dev b/bin/dev index deff0635..6230106c 100644 --- a/bin/dev +++ b/bin/dev @@ -10,16 +10,24 @@ gaze('src/**/*', function(err, watcher) { if (err) throw err; watcher.on('changed', function(file) { console.log(file + " has changed"); - fs.writeFile(file.replace(/\/src\//, "/lib/"), babel.transformFileSync(file).code); + try { + fs.writeFile(file.replace(/\/src\//, "/lib/"), babel.transformFileSync(file).code); + } catch (e) { + console.error(e.message, e.stack); + } }); }); -// Run and watch dist -nodemon({ - script: 'bin/parse-server', - ext: 'js json', - watch: 'lib' -}); +try { + // Run and watch dist + nodemon({ + script: 'bin/parse-server', + ext: 'js json', + watch: 'lib' + }); +} catch (e) { + console.error(e.message, e.stack); +} process.once('SIGINT', function() { process.exit(0);