Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda