sezna / nps

NPM Package Scripts -- All the benefits of npm scripts without the cost of a bloated package.json and limits of json
MIT License
1.43k stars 93 forks source link

point `default` to named script #208

Open pvinis opened 4 years ago

pvinis commented 4 years ago

This is not really a problem, more of a question.

Can I have something like

module.exports = {
  build: 'yarn some-build-cmd',
  dev: 'yarn some-other-cmd',
  default: // <-- here goes a way to point to `dev`
}

Basically I would like to have a named script, and to point to it as the default.

This would mostly be useful in cases like

{
  ios: {
    alpha: {
      x: 'bla alpha',
      nonX: 'blu alpha',
    },
    beta: {
      x: 'bla beta',
      nonX: 'blu beta',
    },
  },
  default: // some way to point to ios.alpha.nonX
}
sezna commented 4 years ago

I don't see any problems with this request. Looks good to me.

evdhiggins commented 4 years ago

Perhaps I'm missing something, but couldn't this be achieved by directly calling the desired script from default?

e.g.

module.exports = {
  build: 'yarn some-build-cmd',
  dev: 'yarn some-other-cmd',
  default: 'nps build'
}

This will result in nps logging two separate script executions to the console, but I can't imagine that an additional configuration would be more succinct.

I suppose that this wouldn't work very well in a case where you wanted to pass dynamic arguments from the command line to the 2nd named script.

pvinis commented 4 years ago

🤔 I guess that makes sense, but it would be nice to have support for args. hmm