-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path7-mixin.js
More file actions
20 lines (17 loc) · 508 Bytes
/
Copy path7-mixin.js
File metadata and controls
20 lines (17 loc) · 508 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';
const fs = require('node:fs');
const { readFile } = fs;
fs.readFile = (...args) => {
const path = args.shift();
const callback = args.pop();
const options = args.pop() || {};
console.log(`Intercepted call: fs.readFile('${path}')`);
return readFile(path, options, (err, data) => {
if (err) console.error(err);
else console.log(`Data received: ${data.length}`);
callback(err, data);
});
};
fs.readFile('./7-mixin.js', (err, data) => {
console.log({ err, data });
});