Skip to content

Configuration Clashing #113

Closed
Closed
@wyattjoh

Description

@wyattjoh

We have a package.json:

{
  "name": "talk",
  "scripts": {
    "a": "npm-run-all a:*",
    "a:a": "echo a",
    "a:b": "echo b",
    "lint": "echo lint"
  },
  "config": {
    "pre-git": {
      "commit-msg": [],
      "pre-commit": [
        "npm-run-all lint",
        "npm-run-all test"
      ],
      "pre-push": [
        "npm-run-all test"
      ],
      "post-commit": [],
      "post-merge": []
    }
  }
}

(truncated for simplicity)

And everytime I try to run yarn a, I get the following:

error Command "--talk:pre_git_pre_commit_0=npm-run-all lint" not found.
error Command "--talk:pre_git_pre_commit_0=npm-run-all lint" not found.

I suspect that the configuration generated by the https://github.com/bahmutov/pre-git package is interfereing with the configuration parsing that's done here:

npm-run-all/lib/index.js

Lines 101 to 124 in 7e83545

/**
* Converts a given config object to an `--:=` style option array.
*
* @param {object|null} config -
* A map-like object to overwrite package configs.
* Keys are package names.
* Every value is a map-like object (Pairs of variable name and value).
* @returns {string[]} `--:=` style options.
*/
function toOverwriteOptions(config) {
const options = []
for (const packageName of Object.keys(config)) {
const packageConfig = config[packageName]
for (const variableName of Object.keys(packageConfig)) {
const value = packageConfig[variableName]
options.push(`--${packageName}:${variableName}=${value}`)
}
}
return options
}

Possibly a way around this?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions