Exit Code always 0
- Dominant language
- JavaScript
- Stars
- 967
- Forks
- 344
- Avg merge
- 8h 41m
- Merged PRs (30d)
- 9
Description
# Bug Report
It would appear the cordova cli always returns an exit code of 0.
I have found this related post which describes a similar issue: https://issues.apache.org/jira/browse/CB-13959
## Problem
In my case I have a hook that executes before platform remove. If this throws an exception, the command stops.
### What is expected to happen?
I expect a non zero exit code
### What does actually happen?
I get an exit code of 0
PS C:\Cordova> lcordova platform rm android
checking file: package.json
File package.json can be read and written
checking file: package-lock.json
File package-lock.json can be read and written
checking file: config.xml
(node:54088) UnhandledPromiseRejectionWarning: Error: File is not writable: config.xml
at \hooks\areKeyFilesWritable.js:40:10
at Array.forEach ()
at module.exports (hooks\areKeyFilesWritable.js:23:8)
at runScriptViaModuleLoader (hooks\HooksRunner.js:157:32)
at runScript (hooks\HooksRunner.js:136:12)
at hooks\HooksRunner.js:108:40
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:54088) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:54088) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PS C:\Cordova>echo $lastExitCode
0
## Information
### Command or Code
config.xml:
areKeyFilesWritable.js
throw new Error("threw an error");
### Environment, Platform, Device
Windows 10, Powershell
### Version information
Cordova Packages:
cli: 10.0.0
common: 4.0.2
create: 3.0.0
lib: 10.0.0
common: 4.0.2
fetch: 3.0.0
serve: 4.0.0
Project Installed Platforms:
android: 9.0.0
Project Installed Plugins:
N/A
Environment:
OS: Microsoft Windows 10 Pro 10.0.17763 (17763) (win32 10.0.17763) x64
Node: v12.18.4
npm: 6.14.6
## Checklist
- [x ] I searched for existing GitHub issues
- [x ] I updated all Cordova tooling to most recent version
- [x ] I included all the necessary information above
Contributor guide
Research direction
Start with the hook execution path shown in hooks/HooksRunner.js and the failing example in hooks/areKeyFilesWritable.js. Reproduce `cordova platform rm android` with a hook that throws, then trace how the rejection reaches the CLI. Done means the command reports a non-zero exit code on Windows PowerShell while preserving normal successful exits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100