From 4937722cf597ccd1953628f3d5e2ab5204280051 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 13 May 2020 11:42:33 +1000 Subject: [PATCH] deps: replace mkdirp with {recursive} mkdir only supported on Node.js 10+ Closes: #2084 PR-URL: https://github.com/nodejs/node-gyp/pull/2123 Reviewed-By: Richard Lau Reviewed-By: Jiawen Geng --- lib/configure.js | 3 +-- lib/install.js | 5 ++--- package.json | 1 - test/test-configure-python.js | 3 ++- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/configure.js b/lib/configure.js index 564564eea4..c164284e7d 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -4,7 +4,6 @@ const fs = require('graceful-fs') const path = require('path') const log = require('npmlog') const os = require('os') -const mkdirp = require('mkdirp') const processRelease = require('./process-release') const win = process.platform === 'win32' const findNodeDirectory = require('./find-node-directory') @@ -73,7 +72,7 @@ function configure (gyp, argv, callback) { function createBuildDir () { log.verbose('build dir', 'attempting to create "build" dir: %s', buildDir) - mkdirp(buildDir, function (err, isNew) { + fs.mkdir(buildDir, { recursive: true }, function (err, isNew) { if (err) { return callback(err) } diff --git a/lib/install.js b/lib/install.js index c919c10588..f9fa2b34bd 100644 --- a/lib/install.js +++ b/lib/install.js @@ -8,7 +8,6 @@ const crypto = require('crypto') const log = require('npmlog') const semver = require('semver') const request = require('request') -const mkdir = require('mkdirp') const processRelease = require('./process-release') const win = process.platform === 'win32' const getProxyFromURI = require('./proxy') @@ -114,7 +113,7 @@ function install (fs, gyp, argv, callback) { log.verbose('ensuring nodedir is created', devDir) // first create the dir for the node dev files - mkdir(devDir, function (err, created) { + fs.mkdir(devDir, { recursive: true }, function (err, created) { if (err) { if (err.code === 'EACCES') { eaccesFallback(err) @@ -310,7 +309,7 @@ function install (fs, gyp, argv, callback) { log.verbose(name, 'dir', dir) log.verbose(name, 'url', libUrl) - mkdir(dir, function (err) { + fs.mkdir(dir, { recursive: true }, function (err) { if (err) { return done(err) } diff --git a/package.json b/package.json index 707524e846..a71dd64370 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "env-paths": "^2.2.0", "glob": "^7.1.4", "graceful-fs": "^4.2.3", - "mkdirp": "^0.5.1", "nopt": "^4.0.3", "npmlog": "^4.1.2", "request": "^2.88.2", diff --git a/test/test-configure-python.js b/test/test-configure-python.js index d08f9e5ed3..ac25f7972e 100644 --- a/test/test-configure-python.js +++ b/test/test-configure-python.js @@ -10,7 +10,8 @@ const configure = requireInject('../lib/configure', { openSync: function () { return 0 }, closeSync: function () { }, writeFile: function (file, data, cb) { cb() }, - stat: function (file, cb) { cb(null, {}) } + stat: function (file, cb) { cb(null, {}) }, + mkdir: function (dir, options, cb) { cb() } } })