From 78b08c73cc956853b49addce708561a3fcb7e19f Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Fri, 26 Mar 2021 23:57:02 +0100 Subject: [PATCH] log on warn and log+exit on error --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4f370e8..6a7b2ea 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,12 @@ function remove(root, done) { if (path.basename(dir.fullPath) === 'node_modules') { dirs.push(dir.fullPath); } - }).once('end', function() { + }).on('warn', function(err) { + console.warn('Non-fatal error:', err.message); + }).on('error', function(err) { + console.error('Fatal error:', err); + done(err); + }).on('end', function() { map(dirs, 1, function(dirname, next) { if (fs.existsSync(dirname)) { rimraf(dirname, next);