Skip to content

Instantly share code, notes, and snippets.

@mendes5
Created July 6, 2023 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mendes5/6331d0bf3de1dd56c2a8d6ce946f5210 to your computer and use it in GitHub Desktop.
Save mendes5/6331d0bf3de1dd56c2a8d6ce946f5210 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const { stat, statfs, statSync, statfsSync } = fs;
Object.assign(fs, {
stat(){
console.log('Running stat', arguments[0], new Error().stack);
return stat.call(fs, ...[...arguments]);
},
statfs(){
console.log('Running statfs', arguments[0], new Error().stack);
return statfs.call(fs, ...[...arguments]);
},
statSync(){
console.log('Running statSync', arguments[0], new Error().stack);
return statSync.call(fs, ...[...arguments]);
},
statfsSync(){
console.log('Running statfsSync', arguments[0], new Error().stack);
return statfsSync.call(fs, ...[...arguments]);
},
});
node -r hack.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment