/
_config.js
43 lines (41 loc) · 965 Bytes
/
_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const assert = require('assert');
const { promises: fs } = require('fs');
const { wait } = require('../../../../../utils');
const fsReadFile = fs.readFile;
let currentReads = 0;
let maxReads = 0;
module.exports = {
description: 'maxParallelFileReads with plugin',
options: {
strictDeprecations: false,
maxParallelFileReads: 3,
plugins: [
{
load(id) {
return fs.readFile(id, 'utf-8');
}
}
]
},
before() {
fs.readFile = async (path, options) => {
currentReads++;
maxReads = Math.max(maxReads, currentReads);
const content = await fsReadFile(path, options);
await wait(50);
currentReads--;
return content;
};
},
after() {
fs.readFile = fsReadFile;
assert.strictEqual(maxReads, 3, 'Wrong number of parallel file reads: ' + maxReads);
},
warnings: [
{
code: 'DEPRECATED_FEATURE',
message:
'The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.'
}
]
};