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": {