From 45e62bd1cbb92cb0df9e679d8812999638bd06b3 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Sun, 21 Feb 2021 21:39:11 +0900 Subject: [PATCH 1/2] refactor: do not depend on deprecated constatnts module --- polyfills.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/polyfills.js b/polyfills.js index 1287da1..a9adbff 100644 --- a/polyfills.js +++ b/polyfills.js @@ -1,4 +1,4 @@ -var constants = require('constants') +var constants = require('fs').constants var origCwd = process.cwd var cwd = null @@ -31,7 +31,7 @@ function patch (fs) { // lchmod, broken prior to 0.6.2 // back-port the fix here. - if (constants.hasOwnProperty('O_SYMLINK') && + if (constants.O_SYMLINK !== undefined && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { patchLchmod(fs) } @@ -199,7 +199,7 @@ function patch (fs) { } function patchLutimes (fs) { - if (constants.hasOwnProperty("O_SYMLINK")) { + if (constants.O_SYMLINK !== undefined) { fs.lutimes = function (path, at, mt, cb) { fs.open(path, constants.O_SYMLINK, function (er, fd) { if (er) { From ad7601acebe11108d2928c31c7d0c6f7ca82d306 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Sat, 6 Mar 2021 01:48:37 +0900 Subject: [PATCH 2/2] Fallback to require('constants') when fs.constants is unavailable Co-authored-by: Corey Farrell --- polyfills.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polyfills.js b/polyfills.js index a9adbff..443881a 100644 --- a/polyfills.js +++ b/polyfills.js @@ -1,4 +1,4 @@ -var constants = require('fs').constants +var constants = require('fs').constants || require('constants') var origCwd = process.cwd var cwd = null