MCPcopy Index your code
hub / github.com/angular/angular / patchFs

Function patchFs

packages/zone.js/lib/node/fs.ts:12–89  ·  view source on GitHub ↗
(Zone: ZoneType)

Source from the content-addressed store, hash-verified

10import {ZoneType} from '../zone-impl';
11
12export function patchFs(Zone: ZoneType): void {
13 Zone.__load_patch('fs', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
14 let fs: any;
15 try {
16 fs = require('fs');
17 } catch (err) {}
18
19 if (!fs) return;
20
21 // watch, watchFile, unwatchFile has been patched
22 // because EventEmitter has been patched
23 const TO_PATCH_MACROTASK_METHODS = [
24 'access',
25 'appendFile',
26 'chmod',
27 'chown',
28 'close',
29 'exists',
30 'fchmod',
31 'fchown',
32 'fdatasync',
33 'fstat',
34 'fsync',
35 'ftruncate',
36 'futimes',
37 'lchmod',
38 'lchown',
39 'lutimes',
40 'link',
41 'lstat',
42 'mkdir',
43 'mkdtemp',
44 'open',
45 'opendir',
46 'read',
47 'readdir',
48 'readFile',
49 'readlink',
50 'realpath',
51 'rename',
52 'rmdir',
53 'stat',
54 'symlink',
55 'truncate',
56 'unlink',
57 'utimes',
58 'write',
59 'writeFile',
60 'writev',
61 ];
62
63 TO_PATCH_MACROTASK_METHODS.filter(
64 (name) => !!fs[name] && typeof fs[name] === 'function',
65 ).forEach((name) => {
66 patchMacroTask(fs, name, (self: any, args: any[]) => {
67 return {
68 name: 'fs.' + name,
69 args: args,

Callers 1

patchNodeFunction · 0.90

Calls 5

patchMacroTaskFunction · 0.90
__load_patchMethod · 0.65
symbolMethod · 0.65
forEachMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…