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

depcheck not triggering fail from bashscript- #171

Closed
SameerSiddiqui opened this issue Oct 5, 2016 · 14 comments
Closed

depcheck not triggering fail from bashscript- #171

SameerSiddiqui opened this issue Oct 5, 2016 · 14 comments

Comments

@SameerSiddiqui
Copy link

I have a bashscript which executes git/grunt commands automatically, checks for outdated packages and updates/publishes/deploys the app on npm and git.

i want to introduce depcheck in my script so i did the following.

depcheck --ignores '@cv/package1, package2, package3, @cv/package4'
                    if [ $? -eq 0 ]; then 
                                              #i go forward with my publish-
                        echo "Step-11: Checking Command to execute" 
                    else 
                     echo "Missing Dependencies found. Fix the package.json file and execute this script again."
                        exit 3
                    fi

But bash is not detecting if depcheck command has failed. if i assign the depcheck command to variable i do get result but why isn't bash detecting it automatically with $? -eq 0 i have many grunt commands like jshint- and i check them with if [ $? -eq 0 ]; and it works.

Am i doing something wrong or this feature is not available with depcheck ?

@fastcodejava
Copy link

Yeah, seems like an valid issue.

@lijunle
Copy link
Member

lijunle commented Dec 6, 2016

@SameerSiddiqui Did you resolve your problem? It sounds like not a problem from depcheck side.

@mnkhouri
Copy link
Member

I'm unable to reproduce this today -- please feel free to reopen an issue if you continue to see this!

@spiray
Copy link

spiray commented Dec 18, 2019

@mnkhouri This still doesn't work for me. This is my script -

#!/bin/bash

npx depcheck
if [[ $? == 1 ]]; then
    exit 1
else
    echo "All of the dependencies are up to date!!!"
fi

And this is the output -

Unused dependencies
* exponentiation
Unused devDependencies
* @commitlint/config-conventional
* commitlint
* husky
* mysql
All of the dependencies are up to date!!!

Any ideas?

@rumpl
Copy link
Member

rumpl commented Dec 18, 2019

The error code is not 1 but 255 (-1)

@spiray
Copy link

spiray commented Dec 18, 2019

@rumpl thanks for the quick response, that doesn't seem to be the case, to simplify it, when I run

npx depcheck
echo $?

I get -

Unused dependencies
* exponentiation
Unused devDependencies
* @commitlint/config-conventional
* commitlint
* husky
* mysql
0

@rumpl
Copy link
Member

rumpl commented Dec 18, 2019

Just did the same:

➜  front git:(master) ✗ cat test.sh 
#!/bin/bash

npx depcheck
echo $?
➜  front git:(master) ✗ ./test.sh 
Missing dependencies
* eslint-config-react-app
* babel-eslint
* eslint-plugin-import
* eslint-plugin-flowtype
* eslint-plugin-jsx-a11y
* eslint-plugin-react
* eslint-plugin-react-hooks
255

@spiray
Copy link

spiray commented Dec 18, 2019

You have missing dependencies, maybe that is why. Can you test it again where you only have unused deps?

@rumpl
Copy link
Member

rumpl commented Dec 18, 2019

➜  test ./test.sh 
Unused dependencies
* colors
255

@rumpl
Copy link
Member

rumpl commented Dec 18, 2019

➜  test ./test.sh                     
Unused dependencies
* colors
Unused devDependencies
* request
255

No idea why it's 0 for you...

@spiray
Copy link

spiray commented Dec 18, 2019

Hmm, I'll play around with it a little more

@rumpl
Copy link
Member

rumpl commented Dec 18, 2019

Please do write here what you find, would like to know

@spiray
Copy link

spiray commented Dec 18, 2019

@rumpl I figured out what the issue is, I was using Git Bash for windows. I had a colleague run the same script on MacOs and he got the 255. Thanks!

@rumpl
Copy link
Member

rumpl commented Dec 18, 2019

Thanks!

I wonder why git bash is doing that...

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

No branches or pull requests

6 participants