Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit code #81

Open
alfonsogarciacaro opened this issue Oct 14, 2021 · 2 comments
Open

Exit code #81

alfonsogarciacaro opened this issue Oct 14, 2021 · 2 comments

Comments

@alfonsogarciacaro
Copy link
Contributor

Currently if I run dotnet femto src and I'm missing some npm packages, Femto considers the validation to be successful if there are no UnableToResolve actions:

Femto/src/Program.fs

Lines 869 to 878 in 9035539

let allResolutionActionsCanExecute =
simplifiedActions
|> List.exists (function
| ResolveAction.UnableToResolve(_) -> true
| _ -> false)
|> not
if allResolutionActionsCanExecute
then FemtoResult.ValidationSucceeded
else FemtoResult.ValidationFailed

It'd be nice to have a non-zero exit code in this case. Let's say I have a repo with multiple Fable apps and different developers working on each. Each app has its own package.json and I want to be sure all developers are installing the correct npm dependencies when they add a Nuget Fable package so I add dotnet femto to the CI to check all the apps. But Femto will only display the resolution actions and won't make the build script fail. It's true that devs should use dotnet femto install for new packages and that we should notice missing npm dependencies by manually checking the app or with (ehem) tests, but by running Femto in CI I can make sure that the right versions of the npm packages are installed.

Besides that, FemtoResult enumeration containst non-zero codes for "successful" outcomes, like PackageInstalled. Again, (un)install commands will probably be run in a terminal and not in a script, but who knows:

Femto/src/Prelude.fs

Lines 3 to 19 in 9035539

type FemtoResult =
| UnexpectedError = -1
| ValidationSucceeded = 0
| MissingPackageJson = 1
| NodeModulesNotInstalled = 2
| ValidationFailed = 3
| ProjectFileNotFound = 4
| ProjectCrackerFailed = 5
| UsageRequested = 6
| InvalidArguments = 7
| NugetInstallationFailed = 8
| NugetInstallationSucceeded = 9
| PaketInstallationFailedNoPaketDependencies = 10
| PaketInstallationSucceeded = 11
| PaketNotFound = 12
| PaketFailed = 13
| PackageUninstalled = 14

@Zaid-Ajaj
Copy link
Owner

Hi @alfonsogarciacaro, just realized I haven't answered this in a while 😅 what you say makes sense, what do you think about a new argument ci which validates missing packages? i.e.

femto ci

which is basically just femto but returns exit code 0 when everything is fine

@alfonsogarciacaro
Copy link
Contributor Author

I forgot about this too! If you prefer to not make this the default and have it under a flag (still think it'd be nice if Femto exit code followed the usual convention: 0 success, >= 1 some problem), I would rather pick something with more obvious semantics like --strict.

Please note the issue is about the exit code, not about throwing an error. If I'm not mistaken, the result code will have no effect if femto is executed directly in the terminal, only when it's called by a script (and only when the script decides to check the exit code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants