From 2c14fa9e319a39bcfc0b678a4879b236cbcfbe5a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 31 Oct 2016 20:17:27 -0600 Subject: [PATCH 1/2] Revert "Confirm that mock-fs works if another file requires fs-extra first" This reverts commit 97c89a54df6f7230e716bf6067dbdc55b9738992. --- package.json | 1 - test/integration/A.spec.js | 15 --------------- test/integration/B.spec.js | 28 ---------------------------- test/{ => lib}/.eslintrc | 0 4 files changed, 44 deletions(-) delete mode 100644 test/integration/A.spec.js delete mode 100644 test/integration/B.spec.js rename test/{ => lib}/.eslintrc (100%) diff --git a/package.json b/package.json index ccad043f..2a4cb154 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "chai": "3.5.0", "eslint": "2.13.0", "eslint-config-tschaub": "6.0.0", - "fs-extra": "^0.30.0", "mocha": "3.1.2", "rimraf": "2.5.4" }, diff --git a/test/integration/A.spec.js b/test/integration/A.spec.js deleted file mode 100644 index e75dff16..00000000 --- a/test/integration/A.spec.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This test is here so that fs-extra is required before mock-fs in the - * B.spec.js file. - * - * See https://github.com/tschaub/mock-fs/issues/103 - */ - -var assert = require('../helper').assert; -var fs = require('fs-extra'); - -describe('Dummy test A', function() { - it('should pass', function() { - assert.equal(typeof fs, 'object'); - }); -}); diff --git a/test/integration/B.spec.js b/test/integration/B.spec.js deleted file mode 100644 index c66e6c2a..00000000 --- a/test/integration/B.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * The A.spec.js file requires fs-extra before this one. Here we confirm that - * mock-fs still works even if fs-extra was required elsewhere first. - * - * See https://github.com/tschaub/mock-fs/issues/103 - */ - -var assert = require('../helper').assert; -var mock = require('../../lib/index'); -var fs = require('fs-extra'); - -describe('Dummy test B', function() { - before(function() { - mock({ - folder: {} - }); - }); - - after(function() { - mock.restore(); - }); - - it('should read mocked directory', function() { - var content = fs.readdirSync('folder'); - assert.isArray(content); - }); - -}); diff --git a/test/.eslintrc b/test/lib/.eslintrc similarity index 100% rename from test/.eslintrc rename to test/lib/.eslintrc From 69b568549649df3d8c7f82c40adfed2b24a0ec49 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 31 Oct 2016 20:17:51 -0600 Subject: [PATCH 2/2] Revert "Clear the require cache before overriding fs" This reverts commit 51bc0fbd4d032b987101324f95a614864b86c674. --- lib/index.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/index.js b/lib/index.js index c4a4f1b7..12d3980d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,15 +1,5 @@ 'use strict'; -/** - * Clear the require cache so that other modules that patch fs get evaulated - * again after this one. - */ -Object.keys(require.cache).forEach(function(key) { - if (key.indexOf(__dirname) === -1) { - delete require.cache[key]; - } -}); - var realFs = require('fs'); var path = require('path');