diff --git a/CHANGELOG.md b/CHANGELOG.md index 93a0ae96ad..a0b19715e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This is the log of notable changes to EAS CLI and related packages. ### ๐Ÿ› Bug fixes - Fix files deleted in working directory not being removed from the project archive when `requireCommit` is false. ([#2900](https://github.com/expo/eas-cli/pull/2900) by [@sjchmiela](https://github.com/sjchmiela)) +- In `EAS_NO_VCS=1`, ask Git for repository root when `EAS_PROJECT_ROOT` is not set. ([#2901](https://github.com/expo/eas-cli/pull/2901) by [@sjchmiela](https://github.com/sjchmiela)) ### ๐Ÿงน Chores diff --git a/packages/eas-cli/src/vcs/clients/noVcs.ts b/packages/eas-cli/src/vcs/clients/noVcs.ts index af6d66e776..b436a4133b 100644 --- a/packages/eas-cli/src/vcs/clients/noVcs.ts +++ b/packages/eas-cli/src/vcs/clients/noVcs.ts @@ -14,15 +14,16 @@ export default class NoVcsClient extends Client { } public async getRootPathAsync(): Promise { + // If EAS_PROJECT_ROOT is absolute, return it. + // If it is relative or empty, resolve it from Git root or process.cwd(). + // Honor `EAS_PROJECT_ROOT` if it is set. - if (process.env.EAS_PROJECT_ROOT) { - const rootPath = process.env.EAS_PROJECT_ROOT; - // `path.resolve()` will return `rootPath` if it is absolute - // (which is what we want). - return path.resolve(process.cwd(), rootPath); + if (process.env.EAS_PROJECT_ROOT && path.isAbsolute(process.env.EAS_PROJECT_ROOT)) { + return path.normalize(process.env.EAS_PROJECT_ROOT); } // If `EAS_PROJECT_ROOT` is not set, try to get the root path from Git. + let resolveRoot = process.cwd(); try { return ( await spawnAsync('git', ['rev-parse', '--show-toplevel'], { @@ -35,9 +36,9 @@ export default class NoVcsClient extends Client { Log.warn( 'You can set `EAS_PROJECT_ROOT` environment variable to let eas-cli know where your project is located.' ); - - return process.cwd(); } + + return path.resolve(resolveRoot, process.env.EAS_PROJECT_ROOT ?? '.'); } public async makeShallowCopyAsync(destinationPath: string): Promise {