Performance: process.cwd and __dirname
LOW IMPACT
This concept affects how file paths are resolved during runtime, impacting module loading speed and script execution consistency.
const path = require('path'); const filePath = path.join(__dirname, 'data', 'file.txt');
const path = require('path'); const filePath = path.join(process.cwd(), 'data', 'file.txt');
| Pattern | Path Stability | File System Calls | Error Risk | Verdict |
|---|---|---|---|---|
| Using process.cwd() | Variable depending on run location | Potentially more calls due to retries | Higher risk of path errors | [X] Bad |
| Using __dirname | Stable and fixed to script location | Minimal calls, direct path | Low risk of errors | [OK] Good |