Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda