From b186df6b25b01ccaf57cea3b6ae6328830cc30ba Mon Sep 17 00:00:00 2001 From: xzyfer Date: Thu, 7 Nov 2019 22:04:00 +1100 Subject: [PATCH] Remove async-foreach dependency Fixes #2487 --- .eslintrc.json | 1 + bin/node-sass | 26 +++++++++++++------------- package.json | 1 - 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d183f888b..f95dfbb33 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,6 @@ { "env": { + "es6": true, "node": true }, "globals": {}, diff --git a/bin/node-sass b/bin/node-sass index 763fb496d..658f00b20 100755 --- a/bin/node-sass +++ b/bin/node-sass @@ -1,7 +1,7 @@ #!/usr/bin/env node var Emitter = require('events').EventEmitter, - forEach = require('async-foreach').forEach, + promisify = require('util').promisify, chokidar = require('chokidar'), meow = require('meow'), util = require('util'), @@ -410,19 +410,19 @@ function renderDir(options, emitter, done) { return emitter.emit('error', 'No input file was found.'); } - forEach(files, function(subject) { - renderFile(subject, options, emitter, this.async()); - }, function(successful, arr) { - var outputDir = path.join(process.cwd(), options.output); - if (!options.quiet) { - emitter.emit('info', util.format('Wrote %s CSS files to %s', arr.length, outputDir)); - } - if (successful) { - done(); - } else { + Promise.all(files.map(function(subject) { + return promisify(renderFile)(subject, options, emitter); + })) + .then(function(res) { + var outputDir = path.join(process.cwd(), options.output); + if (!options.quiet) { + emitter.emit('info', util.format('Wrote %s CSS files to %s', res.length, outputDir)); + } + }) + .then(done) + .catch(function() { done(new Error('Some files failed to compile')); - } - }); + }); }); } diff --git a/package.json b/package.json index 392daa0f5..c0f49d449 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,6 @@ "style" ], "dependencies": { - "async-foreach": "^0.1.3", "chalk": "^2.4.2", "chokidar": "^3.3.0", "cross-spawn": "^7.0.1",