jzaefferer / commitplease

Validates strings as commit messages
87 stars 17 forks source link

Add getProjectPath() to compute path to parent project #98

Closed alisianoi closed 7 years ago

alisianoi commented 7 years ago

Previously, process.cwd() did the job just fine but with node v8.1.2 (compared to 7.10.0 at least) the output has changed. So, use the following hack: when installing a node package, npm adds it to PATH. Since we know: a) the suffix of that path entry (commitplease/node_modules/.bin) b) the fact that the other project is installing commitplease

then find that entry and use its prefix as parent project path

Refs: https://github.com/jquery/jquery/issues/3708

jzaefferer commented 7 years ago

Looks alright to me. Can we do this without adding the ends-with dependency?

alisianoi commented 7 years ago

I see two ways here: drop node 0.12 (which I know you secretly want to, wink-wink) or code it completely by hand. Your choice.

jzaefferer commented 7 years ago

Let's drop node 0.12! Anything before 4.x has been dead to me for a while :shipit:

jzaefferer commented 7 years ago

Can bump a major version to make that drop more obvious.

alisianoi commented 7 years ago

Ok, done. I've also manually tested installing/uninstalling commitplease which resulted in further changes to getProjectPath, please try it out before you decide to merge. The install.js script needed adjusting because path.relative also relies on current working directory (source https://nodejs.org/api/path.html#path_path_relative_from_to) and silently failed to work properly too. Should be alright now though.

alisianoi commented 7 years ago

Spoke too soon. Travis tells me I have not accounted for self-install. Fair enough, let me hack a bit more.

alisianoi commented 7 years ago

Add early opt-out check for self-install, ready for review.

jzaefferer commented 7 years ago

Let's land it.

alisianoi commented 7 years ago

Done, I've also written a short release summary:

https://github.com/jzaefferer/commitplease/releases/tag/v3.0.0

The v3.1.0 tag is there just not to bother with picking/rebasing the v3.0.0 tag.

jzaefferer commented 7 years ago

Nice :-) Summary is looking good, helps explain the major version bump.