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

postversion with yarn does not work as expected #58

Closed
suside opened this issue Jun 12, 2018 · 6 comments
Closed

postversion with yarn does not work as expected #58

suside opened this issue Jun 12, 2018 · 6 comments

Comments

@suside
Copy link
Contributor

suside commented Jun 12, 2018

When you add
"postversion": "react-native-version"
and run
npm version --new-version patch
you will end up with latest tag and HEAD having fallowing files updated:

 android/app/build.gradle      | 4 ++--
 ios/MyProject/Info.plist      | 6 +++---
 ios/MyProjectTests/Info.plist | 4 ++--
 package.json                  | 2 +-

and that is the expected behavior.

But when you do the same with
yarn version --new-version patch
your tag will have only:

 package.json | 2 +-

(with HEAD being ok)

I figured out that this happens because yarn is setting
process.env.npm_config_version_git_tag
instead
process.env.npm_config_git_tag_version
which is then read here:

const latestTag =
(programOpts.amend || process.env.npm_config_git_tag_version) &&
semver.valid(

I'm not sure if yarn is officially supported but the workaround is to use:
"postversion": "react-native-version --amend"
it should work with both npm and yarn

@stovmascript
Copy link
Owner

Whoa, nice find! Is it possible that this variable name was also changed in some new version of npm, or is it really yarn only?

@suside
Copy link
Contributor Author

suside commented Jun 13, 2018

Not sure, I was testing inside project with

$ npm --version
6.0.1
$ yarn --version
1.6.0

and husky precommit enabled.
I will report back as soon as I figure out who and where exactly is setting those env's.

@stovmascript
Copy link
Owner

stovmascript commented Jun 15, 2018

Well, nevertheless, I think we can just add another || for process.env.npm_config_version_git_tag right?

@suside
Copy link
Contributor Author

suside commented Jun 17, 2018

Right, another || will definitely do the job.
But since workaround works I'm going to figure out what's going on underneath before doing any PRs.

@leethree
Copy link

I'm seeing the same problem and @suside 's workaround works. Would be great if it can be fixed.

@suside
Copy link
Contributor Author

suside commented Aug 31, 2018

So it seems they do have different names
https://github.com/yarnpkg/yarn/blob/master/src/registries/yarn-registry.js#L17
vs
https://github.com/npm/cli/blob/latest/lib/config/defaults.js#L150
I'm not sure why.

It seems that another || would be the best solution indeed.

stovmascript added a commit that referenced this issue Aug 31, 2018
Fix #58 Check yarn npm_config_version_git_tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants