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

--silent doesn't work #208

Open
its-dibo opened this issue Dec 25, 2022 · 2 comments
Open

--silent doesn't work #208

its-dibo opened this issue Dec 25, 2022 · 2 comments
Labels

Comments

@its-dibo
Copy link

the following example is from readme.md

{
  "scripts": {
    "clean": "shx --silent rm -rf build dist && shx echo Done",
    "example": "shx --silent ls fakeFileName"
  }
}

output:

npm ERR! Lifecycle script `example` failed with error: 
npm ERR! Error: command failed
@nfischer
Copy link
Member

nfischer commented Feb 9, 2023

I think --silent works as intended in your example. All this flag does is it tells shx to suppress error output, and that's what happened (shx did not print the error message).

The Lifecycle script error message is printed by npm because shx returned a non-zero status code. So if you want to suppress all the error output, I recommend you do as I advised in #210.

I think we could clarify this a bit better in the README documentation by adding a couple examples:

...
$ shx --silent ls fakeFileName  # silence error output

# Add this part:
$ shx --silent ls fakeFileName || shx true # silence error output and ignore the exit status

and also add

{
  "scripts": {
    "clean": "shx rm -rf build dist && shx echo Done",
    "copy-suppress-errors": "shx --silent cp some_file.txt destination/ && shx true"
  }
}

@nfischer nfischer added the docs label Feb 9, 2023
@its-dibo
Copy link
Author

[docs] to be more clear:

--silent suppress the original error but exits with code 1, to ignore the error either use --ignore (if supported) or use shx invalid-cmd || true

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

No branches or pull requests

2 participants