test: Require with empty cache

This commit is contained in:
Felix Rieseberg 2024-10-08 10:49:03 -04:00
parent e25ec9e836
commit 3f80e318cd
5 changed files with 8 additions and 8 deletions

View file

@ -9,13 +9,13 @@ promises.rm = promises.rm || async function (...args) {
const options = args[1] || {} const options = args[1] || {}
try { try {
const stat = await fs.stat(pathToRemove, { throwIfNoEntry: false }) const stat = await promises.stat(pathToRemove, { throwIfNoEntry: false })
const isDirectory = stat.isDirectory() const isDirectory = stat.isDirectory()
if (isDirectory) { if (isDirectory) {
await fs.rmdir(pathToRemove, options) await promises.rmdir(pathToRemove, options)
} else { } else {
await fs.unlink(pathToRemove) await promises.unlink(pathToRemove)
} }
} catch (err) { } catch (err) {
if (err.code === 'ENOENT' && options.force) { if (err.code === 'ENOENT' && options.force) {

View file

@ -10,7 +10,7 @@ const semver = require('semver')
const versionSemver = semver.parse(process.version) const versionSemver = semver.parse(process.version)
const configure = requireInject('../lib/configure', { const configure = requireInject.withEmptyCache('../lib/configure', {
'graceful-fs': { 'graceful-fs': {
openSync: () => 0, openSync: () => 0,
closeSync: () => {}, closeSync: () => {},
@ -26,7 +26,7 @@ const configure = requireInject('../lib/configure', {
} }
}) })
const configure2 = requireInject('../lib/configure', { const configure2 = requireInject.withEmptyCache('../lib/configure', {
'graceful-fs': { 'graceful-fs': {
openSync: () => 0, openSync: () => 0,
closeSync: () => {}, closeSync: () => {},

View file

@ -7,7 +7,7 @@ const { devDir } = require('./common')
const gyp = require('../lib/node-gyp') const gyp = require('../lib/node-gyp')
const requireInject = require('require-inject') const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', { const configure = requireInject.withEmptyCache('../lib/configure', {
'graceful-fs': { 'graceful-fs': {
openSync: () => 0, openSync: () => 0,
closeSync: () => {}, closeSync: () => {},

View file

@ -4,7 +4,7 @@ const { describe, it } = require('mocha')
const assert = require('assert') const assert = require('assert')
const path = require('path') const path = require('path')
const requireInject = require('require-inject') const requireInject = require('require-inject')
const { findAccessibleSync } = requireInject('../lib/util', { const { findAccessibleSync } = requireInject.withEmptyCache('../lib/util', {
'graceful-fs': { 'graceful-fs': {
closeSync: function () { return undefined }, closeSync: function () { return undefined },
openSync: function (path) { openSync: function (path) {

View file

@ -16,7 +16,7 @@ const { download } = require('../lib/download')
describe('install', function () { describe('install', function () {
it('EACCES retry once', async () => { it('EACCES retry once', async () => {
let statCalled = 0 let statCalled = 0
const mockInstall = requireInject('../lib/install', { const mockInstall = requireInject.withEmptyCache('../lib/install', {
'graceful-fs': { 'graceful-fs': {
promises: { promises: {
stat (_) { stat (_) {