Skip to content

Commit 7ea9ab9

Browse files
marcofugaroevilebottnawi
authored andcommitted
feat: relax depth limit from chokidar for content base (#1697)
1 parent 09de43e commit 7ea9ab9

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

lib/Server.js

-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,6 @@ class Server {
948948
ignoreInitial: true,
949949
persistent: true,
950950
followSymlinks: false,
951-
depth: 0,
952951
atomic: false,
953952
alwaysStat: true,
954953
ignorePermissionErrors: true,

test/ContentBase.test.js

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const path = require('path');
4+
const fs = require('fs');
45
const request = require('supertest');
56
const helper = require('./helper');
67
const config = require('./fixtures/contentbase-config/webpack.config');
@@ -17,27 +18,51 @@ const contentBaseOther = path.join(
1718
describe('ContentBase', () => {
1819
let server;
1920
let req;
20-
afterEach(helper.close);
2121

2222
describe('to directory', () => {
23+
const nestedFile = path.join(contentBasePublic, 'assets/example.txt');
24+
25+
jest.setTimeout(30000);
26+
2327
beforeAll((done) => {
2428
server = helper.start(
2529
config,
2630
{
2731
contentBase: contentBasePublic,
32+
watchContentBase: true,
2833
},
2934
done
3035
);
3136
req = request(server.app);
3237
});
3338

39+
afterAll((done) => {
40+
helper.close(() => {
41+
done();
42+
});
43+
fs.truncateSync(nestedFile);
44+
});
45+
3446
it('Request to index', (done) => {
3547
req.get('/').expect(200, /Heyo/, done);
3648
});
3749

3850
it('Request to other file', (done) => {
3951
req.get('/other.html').expect(200, /Other html/, done);
4052
});
53+
54+
it('Watches folder recursively', (done) => {
55+
// chokidar emitted a change,
56+
// meaning it watched the file correctly
57+
server.contentBaseWatchers[0].on('change', () => {
58+
done();
59+
});
60+
61+
// change a file manually
62+
setTimeout(() => {
63+
fs.writeFileSync(nestedFile, 'Heyo', 'utf8');
64+
}, 1000);
65+
});
4166
});
4267

4368
describe('to directories', () => {
@@ -52,6 +77,12 @@ describe('ContentBase', () => {
5277
req = request(server.app);
5378
});
5479

80+
afterAll((done) => {
81+
helper.close(() => {
82+
done();
83+
});
84+
});
85+
5586
it('Request to first directory', (done) => {
5687
req.get('/').expect(200, /Heyo/, done);
5788
});
@@ -73,6 +104,12 @@ describe('ContentBase', () => {
73104
req = request(server.app);
74105
});
75106

107+
afterAll((done) => {
108+
helper.close(() => {
109+
done();
110+
});
111+
});
112+
76113
it('Request to page', (done) => {
77114
req
78115
.get('/other.html')
@@ -93,6 +130,12 @@ describe('ContentBase', () => {
93130
req = request(server.app);
94131
});
95132

133+
afterAll((done) => {
134+
helper.close(() => {
135+
done();
136+
});
137+
});
138+
96139
it('Request to page', (done) => {
97140
req
98141
.get('/foo.html')
@@ -117,6 +160,12 @@ describe('ContentBase', () => {
117160
req = request(server.app);
118161
});
119162

163+
afterAll((done) => {
164+
helper.close(() => {
165+
done();
166+
});
167+
});
168+
120169
it('Request to page', (done) => {
121170
req.get('/other.html').expect(200, done);
122171
});
@@ -137,6 +186,12 @@ describe('ContentBase', () => {
137186
req = request(server.app);
138187
});
139188

189+
afterAll((done) => {
190+
helper.close(() => {
191+
done();
192+
});
193+
});
194+
140195
it('Request to page', (done) => {
141196
req.get('/other.html').expect(404, done);
142197
});
@@ -154,6 +209,12 @@ describe('ContentBase', () => {
154209
req = request(server.app);
155210
});
156211

212+
afterAll((done) => {
213+
helper.close(() => {
214+
done();
215+
});
216+
});
217+
157218
it('Request foo.wasm', (done) => {
158219
req.get('/foo.wasm').expect('Content-Type', 'application/wasm', done);
159220
});

test/fixtures/contentbase-config/public/assets/example.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)