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

259
Views
How do pass an argument to a bash function that is part of an ampersand (&&) chain?

I have a 'script' that runs eslint in my package.json like so:

{
  "name": "overthinkingJs",
  "scripts": {
    "lint": "node lint.js && echo No lint errors"
    "lint": "node lint.js --fix && echo No lint errors"
  }
} 

Where the lint file has this sort of thing, where spawn is from cross-spawn:

const eslint = path.join(__dirname, 'path/to/eslint');
const args = process.argv.slice(2);
spawn(eslint, args, { stdio: 'inherit' })

I'm aware the args = process.argv.slice(2); part means that calling node lint.js --fix passes --fix into eslint.

I'm aware I can make new scripts, but I want a way to pass arbitrary arguments to the first bash process (lint.js) and not the last command (echo) in the ampersand chain?

I've tried:

npm run lint:fix -- --rule 'rule-name: off'

But it runs:

node lint.js --fix && echo No lint errors "--rule" "rule-name: off"

How do I specify which command in the chain to pass arguments to, without changing my lint.js?

about 4 years ago · Juan Pablo Isaza
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!