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

Fix failure to resolve changeset CLI in GitHub Actions #71

Merged
merged 1 commit into from
Feb 15, 2021
Merged

Fix failure to resolve changeset CLI in GitHub Actions #71

merged 1 commit into from
Feb 15, 2021

Conversation

jacobwgillespie
Copy link
Contributor

@jacobwgillespie jacobwgillespie commented Feb 15, 2021

PR #67 broke the action for me for projects that don't use Yarn 2 / PnP. It appears that the issue is that in an Actions environment, the root workspace directory is not a real directory, so it causes issues with a plain require.resolve. When testing the action locally, I didn't catch this error since the workspace directory wasn't a symlink.

This PR uses resolve-from to locate the changeset CLI, like the other PR originally did, as that module has code to work around symlinked directories.

I can confirm that this branch works for my non-Yarn-PnP projects.

@@ -181,20 +182,16 @@ export async function runVersion({
let [versionCommand, ...versionArgs] = script.split(/\s+/);
await exec(versionCommand, versionArgs, { cwd });
} else {
let changesetsCliPkgJson = await require(require.resolve(
"@changesets/cli/package.json",
{ paths: [cwd] }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just call fs.realpathSync just like it does and avoid the dependency?
https://github.com/sindresorhus/resolve-from/blob/4f02820afe9b4e9c379f4bb2745debdb49087d4f/index.js#L16

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as mentioned in #67: tests and robustness. This module is small and is well-used and well tested in the npm ecosystem (it's already present in yarn.lock here, for instance). Also the full code from resolve-from is:

let fromDirectory = cwd
try {
  fromDirectory = fs.realpathSync(fromDirectory)
} catch (error) {
  if (error.code === 'ENOENT') {
    fromDirectory = path.resolve(fromDirectory)
  } else {
    throw error
  }
}

@Andarist Andarist merged commit 640c4a5 into changesets:master Feb 15, 2021
@jacobwgillespie jacobwgillespie deleted the fix-resolve branch February 16, 2021 02:16
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

Successfully merging this pull request may close these issues.

3 participants