From 0c8554797f8ff6f7e84d68a21d38b00b4ebab95a Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Thu, 22 Oct 2020 08:55:58 +0200 Subject: [PATCH] =?UTF-8?q?Use=20mkdirp=20=E2=89=A5=201=20(fixes=20#142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/millstone.js | 15 +++++++++++---- package.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/millstone.js b/lib/millstone.js index 01a59cf..2c9c5b2 100644 --- a/lib/millstone.js +++ b/lib/millstone.js @@ -210,8 +210,14 @@ function localize(url, options, callback) { } } var dir_path = path.dirname(options.filepath); - mkdirp(dir_path, 0755, function(err) { - if (err && err.code !== 'EEXIST') { + mkdirp(dir_path, 0755).then(() => { + download(url, options, function(err, filepath) { + if (err) return callback(err); + callback(null, filepath); + }); + }) + .catch((err) => { + if ( err.code !== 'EEXIST') { if (env == 'development') console.error('[millstone] could not create directory: ' + dir_path); callback(err); } else { @@ -529,8 +535,9 @@ function resolve(options, callback) { benchmark = options.benchmark; Step(function setup() { - if (nosymlink) mkdirp(base, 0755, this); - else mkdirp(path.join(base, 'layers'), 0755, this); + var me = this; + if (nosymlink) mkdirp(base, 0755).then(() => {me()}).catch((e)=>{me(e)}); + else mkdirp(path.join(base, 'layers'), 0755).then(() => {me()}).catch((e)=>{me(e)}); }, function style_externals(err) { if (err && err.code !== 'EEXIST') throw err; if (benchmark) console.time("[millstone][benchmark] Resolving style (mss) externals"); diff --git a/package.json b/package.json index e2a0d3c..6aba46b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "zipfile": "~0.5.5", "sqlite3": "4.1.0", "mime": "~1.2.11", - "mkdirp": "~0.5.0", + "mkdirp": "^1.0.3", "optimist": "~0.6.1" }, "devDependencies": {