mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 04:48:20 +02:00
test: Require with empty cache
This commit is contained in:
parent
e25ec9e836
commit
3f80e318cd
5 changed files with 8 additions and 8 deletions
|
@ -9,13 +9,13 @@ promises.rm = promises.rm || async function (...args) {
|
|||
const options = args[1] || {}
|
||||
|
||||
try {
|
||||
const stat = await fs.stat(pathToRemove, { throwIfNoEntry: false })
|
||||
const stat = await promises.stat(pathToRemove, { throwIfNoEntry: false })
|
||||
const isDirectory = stat.isDirectory()
|
||||
|
||||
if (isDirectory) {
|
||||
await fs.rmdir(pathToRemove, options)
|
||||
await promises.rmdir(pathToRemove, options)
|
||||
} else {
|
||||
await fs.unlink(pathToRemove)
|
||||
await promises.unlink(pathToRemove)
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT' && options.force) {
|
||||
|
|
|
@ -10,7 +10,7 @@ const semver = require('semver')
|
|||
|
||||
const versionSemver = semver.parse(process.version)
|
||||
|
||||
const configure = requireInject('../lib/configure', {
|
||||
const configure = requireInject.withEmptyCache('../lib/configure', {
|
||||
'graceful-fs': {
|
||||
openSync: () => 0,
|
||||
closeSync: () => {},
|
||||
|
@ -26,7 +26,7 @@ const configure = requireInject('../lib/configure', {
|
|||
}
|
||||
})
|
||||
|
||||
const configure2 = requireInject('../lib/configure', {
|
||||
const configure2 = requireInject.withEmptyCache('../lib/configure', {
|
||||
'graceful-fs': {
|
||||
openSync: () => 0,
|
||||
closeSync: () => {},
|
||||
|
|
|
@ -7,7 +7,7 @@ const { devDir } = require('./common')
|
|||
const gyp = require('../lib/node-gyp')
|
||||
const requireInject = require('require-inject')
|
||||
|
||||
const configure = requireInject('../lib/configure', {
|
||||
const configure = requireInject.withEmptyCache('../lib/configure', {
|
||||
'graceful-fs': {
|
||||
openSync: () => 0,
|
||||
closeSync: () => {},
|
||||
|
|
|
@ -4,7 +4,7 @@ const { describe, it } = require('mocha')
|
|||
const assert = require('assert')
|
||||
const path = require('path')
|
||||
const requireInject = require('require-inject')
|
||||
const { findAccessibleSync } = requireInject('../lib/util', {
|
||||
const { findAccessibleSync } = requireInject.withEmptyCache('../lib/util', {
|
||||
'graceful-fs': {
|
||||
closeSync: function () { return undefined },
|
||||
openSync: function (path) {
|
||||
|
|
|
@ -16,7 +16,7 @@ const { download } = require('../lib/download')
|
|||
describe('install', function () {
|
||||
it('EACCES retry once', async () => {
|
||||
let statCalled = 0
|
||||
const mockInstall = requireInject('../lib/install', {
|
||||
const mockInstall = requireInject.withEmptyCache('../lib/install', {
|
||||
'graceful-fs': {
|
||||
promises: {
|
||||
stat (_) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue