Open
Description
Is your proposal related to a problem?
When git commit
fails for some reason (e.g. user.name
is not set -- see #6442), CRA swallows git's output and displays a rather cryptic error message:
Git commit not created Error: Command failed: git commit -m "Initialize project using Create React App"
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at tryGitCommit (/home/pastelmind/test-app/node_modules/react-scripts/scripts/init.js:62:5)
at module.exports (/home/pastelmind/test-app/node_modules/react-scripts/scripts/init.js:335:25)
at [eval]:3:14
at Script.runInThisContext (vm.js:116:20)
at Object.runInThisContext (vm.js:306:38)
at Object.<anonymous> ([eval]-wrapper:9:26)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at evalScript (internal/process/execution.js:80:25) {
status: 128,
signal: null,
output: [ null, null, null ],
pid: 2531,
stdout: null,
stderr: null
}
Removing .git directory...
Currently, init.js
calls child_process.spawnSync()
with stdio: 'ignore'
, which completely swallows Git's error message and leaves the user in the dark.
Describe the solution you'd like
Use stdio: 'pipe'
, at least for stderr. Also use encoding: 'utf-8'
(or whatever is appropriate), because otherwise the stdout
is a Buffer object--which isn't really helpful when printed on the terminal.
Describe alternatives you've considered
(Write your answer here.)
Additional context
(Write your answer here.)