-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Git to resolve root path in no-VCS mode
- Loading branch information
Showing
3 changed files
with
83 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import spawnAsync from '@expo/spawn-async'; | ||
import fs from 'fs/promises'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
|
||
import NoVcsClient from '../noVcs'; | ||
|
||
describe('noVcs', () => { | ||
describe('NoVcsClient', () => { | ||
let vcs: NoVcsClient; | ||
let repoRoot: string; | ||
let globalEasProjectRoot: string | undefined; | ||
|
||
afterAll(async () => { | ||
await fs.rm(repoRoot, { recursive: true, force: true }); | ||
process.env.EAS_PROJECT_ROOT = globalEasProjectRoot; | ||
}); | ||
|
||
beforeAll(async () => { | ||
repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-')); | ||
|
||
vcs = new NoVcsClient({ cwdOverride: repoRoot }); | ||
globalEasProjectRoot = process.env.EAS_PROJECT_ROOT; | ||
delete process.env.EAS_PROJECT_ROOT; | ||
}); | ||
|
||
it('should return the current working directory when not in Git repository', async () => { | ||
expect(await vcs.getRootPathAsync()).toBe(process.cwd()); | ||
}); | ||
|
||
it('should return the Git root when in Git repository', async () => { | ||
await spawnAsync('git', ['init'], { cwd: repoRoot }); | ||
expect(await fs.realpath(await vcs.getRootPathAsync())).toBe(await fs.realpath(repoRoot)); | ||
}); | ||
|
||
it('should return the project root when EAS_PROJECT_ROOT is set', async () => { | ||
process.env.EAS_PROJECT_ROOT = 'project-root'; | ||
expect(await vcs.getRootPathAsync()).toBe(path.resolve(process.cwd(), 'project-root')); | ||
|
||
process.env.EAS_PROJECT_ROOT = '/app'; | ||
expect(await vcs.getRootPathAsync()).toBe('/app'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters