From 1e50616c1383820f87173e562fa83d1c976d3a8b Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 31 Jan 2020 15:05:50 -0500 Subject: [PATCH] fix: handle mkdirp0.5->1.0x so it doesn't break upgrade --- src/meta/js.js | 9 ++++++++- src/meta/languages.js | 5 +++-- src/meta/sounds.js | 7 ++++--- src/meta/templates.js | 6 +++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/meta/js.js b/src/meta/js.js index aa5126ef5f..aa329022d9 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -5,7 +5,14 @@ var async = require('async'); var fs = require('fs'); const util = require('util'); var mkdirp = require('mkdirp'); -var mkdirpCallback = util.callbackify(mkdirp); +var mkdirpCallback; +if (mkdirp.hasOwnProperty('native')) { + mkdirpCallback = util.callbackify(mkdirp); +} else { + mkdirpCallback = mkdirp; + mkdirp = util.promisify(mkdirp); +} + var rimraf = require('rimraf'); var file = require('../file'); diff --git a/src/meta/languages.js b/src/meta/languages.js index 940de715d3..7f4afd0a02 100644 --- a/src/meta/languages.js +++ b/src/meta/languages.js @@ -2,11 +2,12 @@ const path = require('path'); const fs = require('fs'); -const mkdirp = require('mkdirp'); +const util = require('util'); +let mkdirp = require('mkdirp'); +mkdirp = mkdirp.hasOwnProperty('native') ? mkdirp : util.promisify(mkdirp); const rimraf = require('rimraf'); const _ = require('lodash'); -const util = require('util'); const rimrafAsync = util.promisify(rimraf); const writeFileAsync = util.promisify(fs.writeFile); const readFileAsync = util.promisify(fs.readFile); diff --git a/src/meta/sounds.js b/src/meta/sounds.js index 4b4b08c377..3c6fb6eff3 100644 --- a/src/meta/sounds.js +++ b/src/meta/sounds.js @@ -2,11 +2,12 @@ const path = require('path'); const fs = require('fs'); -const rimraf = require('rimraf'); -const mkdirp = require('mkdirp'); - const util = require('util'); +const rimraf = require('rimraf'); +let mkdirp = require('mkdirp'); +mkdirp = mkdirp.hasOwnProperty('native') ? mkdirp : util.promisify(mkdirp); + const readdirAsync = util.promisify(fs.readdir); const rimrafAsync = util.promisify(rimraf); const writeFileAsync = util.promisify(fs.writeFile); diff --git a/src/meta/templates.js b/src/meta/templates.js index 21318e7ce0..e3f5005d78 100644 --- a/src/meta/templates.js +++ b/src/meta/templates.js @@ -1,11 +1,11 @@ 'use strict'; -const mkdirp = require('mkdirp'); +const util = require('util'); +let mkdirp = require('mkdirp'); +mkdirp = mkdirp.hasOwnProperty('native') ? mkdirp : util.promisify(mkdirp); const rimraf = require('rimraf'); const winston = require('winston'); const path = require('path'); - -const util = require('util'); const fs = require('fs'); const fsReadFile = util.promisify(fs.readFile); const fsWriteFile = util.promisify(fs.writeFile);