4.0.0 • Published 1 year ago

exec-if-exists v4.0.0

Weekly downloads
208
License
MIT
Repository
github
Last release
1 year ago

exec-if-exists

Runs an npm package (e.g. npm exec) only if it exists locally (e.g. in node_modules). The default npx command will run packages found both locally and globally and if the package doesn't exist throw an error.

Usage

exec-if-exists sortier ./src/**/*.ts

Why?

Maintaining a shared config but allowing opt-in dev tooling. Take the following example lint-staged config:

// Example lint-staged config
{
  // Javascript based source code files
  "**/*.@(?([cm])[jt]s)?(x)": [
      // Required tooling
      "eslint --fix",
      "prettier --write --ignore-unknown",

      // Recommended tooling
      "exec-if-exists sortier --ignore-unknown"
  ]
}

Now any time a commit is pushed:

  1. eslint and prettier will run and if they are not installed the commit will fail
  2. sortier, because it's running through exec-if-exists, on the other hand is optional, and only runs if it's installed allowing some flexibility to the consumers of the shared config

The benefit is you can document in a single location

  • optional tooling you maybe testing to making required in the future
  • optional tooling that people have suggested that may benefit others

Either way it allows easy opt-in to tooling without having to change a shared configuration file.

Finally, you can now use that shared config:

const configs = require("@snowcoders/renovate-config");

module.exports = configs.lintStaged;
4.0.0-beta.3

1 year ago

4.0.0-beta.2

1 year ago

4.0.0-beta.1

1 year ago

4.0.0-beta.0

1 year ago

4.0.0

1 year ago

3.0.4

3 years ago

3.0.4-beta.0

3 years ago

3.0.3

3 years ago

3.0.3-alpha.0

3 years ago

3.0.3-alpha.1

3 years ago

3.0.3-alpha.2

3 years ago

3.0.2

4 years ago

3.0.2-alpha.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago