-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from log4js-node/fix-fs-extra-error-on-init
chore(dep): temporary fix for fs-extra issue (to be reverted when fs-extra patches it)
- Loading branch information
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const should = require("should"); | ||
const path = require("path"); | ||
|
||
describe("simulate fs monkey-patch", function() { | ||
const fs = require("fs"); | ||
const realpathNativeBackup = fs.realpath.native; | ||
|
||
beforeEach(function() { | ||
// simulate fs monkey-patch | ||
delete fs.realpath.native; | ||
}); | ||
|
||
afterEach(function() { | ||
// reset require.cache | ||
delete require.cache[require.resolve("../lib/RollingFileWriteStream")]; | ||
delete require.cache[require.resolve("../lib/moveAndMaybeCompressFile")]; | ||
const fsePath = path.dirname(require.resolve("fs-extra")); | ||
for (const entry in require.cache) { | ||
if (entry.startsWith(fsePath)) { | ||
delete require.cache[entry] | ||
} | ||
} | ||
// reinstate fs.realpath.native | ||
fs.realpath.native = realpathNativeBackup; | ||
}); | ||
|
||
it("RollingFileWriteStream should not throw error", function() { | ||
console.log(Object.keys(require.cache).length); | ||
should.doesNotThrow(function() { | ||
require("../lib/RollingFileWriteStream"); | ||
}); | ||
console.log(Object.keys(require.cache).length); | ||
}); | ||
|
||
it("moveAndMaybeCompressFile should not throw error", function() { | ||
console.log(Object.keys(require.cache).length); | ||
should.doesNotThrow(function() { | ||
require("../lib/moveAndMaybeCompressFile"); | ||
}); | ||
console.log(Object.keys(require.cache).length); | ||
}); | ||
}); |