(Zone: ZoneType)
| 10 | import {ZoneType} from '../zone-impl'; |
| 11 | |
| 12 | export 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, |
no test coverage detected
searching dependent graphs…