Skip to content

Commit

Permalink
fix(server): revert #1794
Browse files Browse the repository at this point in the history
related #1934
  • Loading branch information
hiroppy committed Jun 5, 2019
1 parent 53f4253 commit 8bd7870
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 75 deletions.
7 changes: 2 additions & 5 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,8 @@ class Server {
if (!this.options.watchOptions) {
this.options.watchOptions = {};
}
// Ignoring node_modules folder by default
this.options.watchOptions.ignored = this.options.watchOptions.ignored || [
/node_modules/,
];
this.watchOptions = this.options.watchOptions;

this.watchOptions = options.watchOptions || {};

// Replace leading and trailing slashes to normalize path
this.sockPath = `/${
Expand Down
70 changes: 0 additions & 70 deletions test/ContentBase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,76 +63,6 @@ describe('ContentBase', () => {
});
});

describe('test ignoring node_modules folder by Default', () => {
beforeAll((done) => {
server = testServer.start(config, {
contentBase: contentBasePublic,
watchContentBase: true,
});
// making sure that chokidar has read all the files
server.contentBaseWatchers[0].on('ready', () => {
done();
});
req = request(server.app);
});

afterAll((done) => {
testServer.close(() => {
done();
});
});

it('Should ignore node_modules & watch bar', (done) => {
const watchedPaths = server.contentBaseWatchers[0].getWatched();
// check if node_modules folder is not in watched list
const folderWatched = !!watchedPaths[
path.join(contentBasePublic, 'node_modules')
];
expect(folderWatched).toEqual(false);
// check if bar folder is in watched list
expect(watchedPaths[path.join(contentBasePublic, 'bar')]).toEqual([
'index.html',
]);

done();
});
});

describe('test not ignoring node_modules folder', () => {
beforeAll((done) => {
server = testServer.start(config, {
contentBase: contentBasePublic,
watchContentBase: true,
watchOptions: {
ignored: /bar/,
},
});
// making sure that chokidar has read all the files
server.contentBaseWatchers[0].on('ready', () => {
done();
});
req = request(server.app);
});

afterAll((done) => {
testServer.close(() => {
done();
});
});

it('Should watch node_modules & ignore bar', (done) => {
const watchedPaths = server.contentBaseWatchers[0].getWatched();
// check if node_modules folder is in watched list
expect(
watchedPaths[path.join(contentBasePublic, 'node_modules')]
).toEqual(['index.html']);
// check if bar folder is not in watched list
const folderWatched = !!watchedPaths[path.join(contentBasePublic, 'bar')];
expect(folderWatched).toEqual(false);
done();
});
});

describe('test listing files in folders without index.html using the option serveIndex:false', () => {
beforeAll((done) => {
server = testServer.start(
Expand Down
Empty file.

0 comments on commit 8bd7870

Please sign in to comment.