Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration Clashing #113

Closed
wyattjoh opened this issue Nov 2, 2017 · 6 comments
Closed

Configuration Clashing #113

wyattjoh opened this issue Nov 2, 2017 · 6 comments

Comments

@wyattjoh
Copy link
Contributor

wyattjoh commented Nov 2, 2017

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?

@mysticatea
Copy link
Owner

mysticatea commented Nov 3, 2017

Thank you for the report.

Hmm, I could not reproduce it.

~\dev\sandbox> npm run a

> talk@ a C:\Users\t-nagashima.MSS\dev\sandbox
> npm-run-all a:*


> talk@ a:a C:\Users\t-nagashima.MSS\dev\sandbox
> echo a

a

> talk@ a:b C:\Users\t-nagashima.MSS\dev\sandbox
> echo b

b

~\dev\sandbox> yarn a
yarn a v0.24.5
$ npm-run-all a:*
yarn run v0.24.5
$ echo a
a
Done in 0.08s.
yarn run v0.24.5
$ echo b
b
Done in 0.08s.
Done in 1.22s.

@mysticatea
Copy link
Owner

Oh, I can reproduce it with the latest yarn. I will investigate more.

@mysticatea
Copy link
Owner

Yarn seems to handle --foo as a task name in yarn run --foo a. This behavior is different to npm.

@wyattjoh
Copy link
Contributor Author

wyattjoh commented Nov 3, 2017

Yeah, we're using yarn with our project, 1.2.1 to be exact.

@karolis-sh
Copy link

I'm having the same issue with yarn version 1.2.1:

{
  "name": "npmrunall",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "config": {
    "msg_1": "message_c_1",
    "msg_2": "message_c_2"
  },
  "scripts": {
    "test0": "run-p test1 test2",
    "test1": "echo $npm_package_config_msg_1",
    "test2": "echo $npm_package_config_msg_2"
  },
  "devDependencies": {
    "npm-run-all": "^4.1.1"
  }
}
17:03 $ yarn test0
yarn run v1.2.1
$ run-p test1 test2
error Command "--npmrunall:msg_2=message_c_2" not found.
error Command "--npmrunall:msg_2=message_c_2" not found.
ERROR: "test1" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@mysticatea
Copy link
Owner

I have published npm-run-all@4.1.2. It should fix this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants