From 911d4db581727ffb0659f54c0ed5560d31da9586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20W=C3=A4rting?= Date: Thu, 24 Jun 2021 10:22:17 +0200 Subject: [PATCH] remove mkdirp dep (#3108) Co-authored-by: Michael Mifsud --- lib/extensions.js | 9 ++++----- lib/render.js | 5 ++--- package.json | 1 - scripts/build.js | 3 +-- scripts/install.js | 7 +++---- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/extensions.js b/lib/extensions.js index b18fd27ac..ce4b17a56 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -4,11 +4,10 @@ var eol = require('os').EOL, fs = require('fs'), - pkg = require('../package.json'), - mkdir = require('mkdirp'), path = require('path'), - defaultBinaryDir = path.join(__dirname, '..', 'vendor'), - trueCasePathSync = require('true-case-path'); + trueCasePathSync = require('true-case-path'), + pkg = require('../package.json'), + defaultBinaryDir = path.join(__dirname, '..', 'vendor'); /** * Get the human readable name of the Platform that is running @@ -352,7 +351,7 @@ function getBinaryCachePath() { cachePath = path.join(cachePathCandidates[i], pkg.name, pkg.version); try { - mkdir.sync(cachePath); + fs.mkdirSync(cachePath, {recursive: true}); return cachePath; } catch (e) { // Directory is not writable, try another diff --git a/lib/render.js b/lib/render.js index 858e02e74..3539a9a16 100644 --- a/lib/render.js +++ b/lib/render.js @@ -4,7 +4,6 @@ var chalk = require('chalk'), fs = require('fs'), - mkdirp = require('mkdirp'), path = require('path'), sass = require('./'); @@ -66,7 +65,7 @@ module.exports = function(options, emitter) { emitter.emit('info', chalk.green('Rendering Complete, saving .css file...')); - mkdirp(path.dirname(destination), function(err) { + fs.mkdir(path.dirname(destination), {recursive: true}, function(err) { if (err) { return emitter.emit('error', chalk.red(err)); } @@ -85,7 +84,7 @@ module.exports = function(options, emitter) { if (sourceMap) { todo++; - mkdirp(path.dirname(sourceMap), function(err) { + fs.mkdir(path.dirname(sourceMap), {recursive: true}, function(err) { if (err) { return emitter.emit('error', chalk.red(err)); } diff --git a/package.json b/package.json index 504449366..4bf517dc7 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "glob": "^7.0.3", "lodash": "^4.17.15", "meow": "^9.0.0", - "mkdirp": "^0.5.1", "nan": "^2.13.2", "node-gyp": "^7.1.0", "npmlog": "^4.0.0", diff --git a/scripts/build.js b/scripts/build.js index 5dcdd4d70..5c8a42b6e 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -3,7 +3,6 @@ */ var fs = require('fs'), - mkdir = require('mkdirp'), path = require('path'), spawn = require('cross-spawn'), sass = require('../lib/extensions'); @@ -24,7 +23,7 @@ function afterBuild(options) { : 'Release', 'binding.node'); - mkdir(path.dirname(install), function(err) { + fs.mkdir(path.dirname(install), {recursive: true}, function(err) { if (err && err.code !== 'EEXIST') { console.error(err.message); return; diff --git a/scripts/install.js b/scripts/install.js index 73740d32d..2cef34f7d 100644 --- a/scripts/install.js +++ b/scripts/install.js @@ -4,11 +4,10 @@ var fs = require('fs'), eol = require('os').EOL, - mkdir = require('mkdirp'), path = require('path'), - sass = require('../lib/extensions'), request = require('request'), log = require('npmlog'), + sass = require('../lib/extensions'), downloadOptions = require('./util/downloadoptions'); /** @@ -111,7 +110,7 @@ function checkAndDownloadBinary() { } try { - mkdir.sync(path.dirname(binaryPath)); + fs.mkdirSync(path.dirname(binaryPath), {recursive: true}); } catch (err) { console.error('Unable to save binary', path.dirname(binaryPath), ':', err); return; @@ -137,7 +136,7 @@ function checkAndDownloadBinary() { console.log('Caching binary to', cachedBinary); try { - mkdir.sync(path.dirname(cachedBinary)); + fs.mkdirSync(path.dirname(cachedBinary), {recursive: true}); fs.createReadStream(binaryPath) .pipe(fs.createWriteStream(cachedBinary)) .on('error', function (err) {