Skip to content

Commit

Permalink
use memfs instead of memory-fs
Browse files Browse the repository at this point in the history
  • Loading branch information
heygrady committed Feb 9, 2019
1 parent 8e54af2 commit b6853ac
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/fs.js
Expand Up @@ -2,7 +2,10 @@

const fs = require('fs');
const path = require('path');
const MemoryFileSystem = require('memory-fs');
const { fs: memfs } = require('memfs');
// borrow join and normalize from memory-fs
memfs.join = require('memory-fs/lib/join');
memfs.normalize = require('memory-fs/lib/normalize');
const { colors } = require('webpack-log');
const NodeOutputFileSystem = require('webpack/lib/node/NodeOutputFileSystem');
const DevMiddlewareError = require('./DevMiddlewareError');
Expand Down Expand Up @@ -60,12 +63,12 @@ module.exports = {

let fileSystem;
// store our files in memory
const isMemoryFs = !compiler.compilers && compiler.outputFileSystem instanceof MemoryFileSystem;
const isMemoryFs = !compiler.compilers && compiler.outputFileSystem === memfs;

if (isMemoryFs) {
fileSystem = compiler.outputFileSystem;
} else {
fileSystem = new MemoryFileSystem();
fileSystem = memfs;
compiler.outputFileSystem = fileSystem;
}

Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -16,6 +16,7 @@
"release": "standard-version"
},
"dependencies": {
"memfs": "^2.15.0",
"memory-fs": "~0.4.1",
"mime": "^2.3.1",
"range-parser": "^1.0.3",
Expand Down
2 changes: 1 addition & 1 deletion test/tests/server.js
Expand Up @@ -390,7 +390,7 @@ describe('Server', () => {
});

it('request to non-public path', (done) => {
request(app).get('/').expect(404, done);
request(app).get('/nonpublic/').expect(404, done);
});
});

Expand Down

0 comments on commit b6853ac

Please sign in to comment.