Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Using jq to extract information about dependencies from package.json

So I am trying to run a jq command inside a makefile to link some dependencies, and I do not understand what the line inside the do-done does. If using only echo "$$dep" I understand what's going on, but when using the full line of code ([ -f "$$dep/package.json" ] && echo "$$dep";) I seem to be lost. Does anyone have any idea? Thanks.

jq -r '.dependencies,.devDependencies|keys[]' $< | while read -r dep; do \
    [ -f "$$dep/package.json" ] && echo "$$dep"; \
done | (piping forward)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since this is in a makefile, there are two things that need to be understood. First, to understand the "$$" variable ($$dep), see this stackoverflow question:

Makefile and use of $$

Second, to understand the ... in do ... done, remember that this is essentially equivalent to a shell conditional of the form:

if [ -f _ ] ; then echo _ ; fi

For details about the test, see e.g. http://wiki.bash-hackers.org/commands/classictest

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!