Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: Node.js
nodejsperformanceasyncchild-process
Prefer async child_process over the sync variants
Use promisified `exec`/`execFile` instead of `execSync` so the call doesn't block the event loop, especially in build plugins and tooling.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | import { execSync } from 'node:child_process'; |
| 2 | const output = execSync(cmd, { cwd: ROOT_DIR, encoding: 'utf-8' }).trim(); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | import { exec } from 'node:child_process'; |
| 2 | import { promisify } from 'node:util'; |
| 3 | const execAsync = promisify(exec); |
| 4 | const { stdout } = await execAsync(cmd, { cwd: ROOT_DIR, encoding: 'utf-8' }); |
Explanation (EN)
Objašnjenje (HR)