Skip to content

Commit f12ee9a

Browse files
fix: auto-fix test failures from Test all (Linux) (#65)
Co-authored-by: kevinwang5658 <20214115+kevinwang5658@users.noreply.github.com>
1 parent 2d9318a commit f12ee9a

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/resources/github-cli/github-cli-alias.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class GithubCliAliasResource extends Resource<GithubCliAliasConfig> {
9696
const $ = getPty();
9797
const { alias, expansion, shell } = plan.desiredConfig;
9898
const shellFlag = shell ? ' --shell' : '';
99-
await $.spawn(`gh alias set ${alias} '${expansion.replace(/'/g, "'\\''")}'${shellFlag}`);
99+
await $.spawn(`gh alias set --clobber ${alias} '${expansion.replace(/'/g, "'\\''")}'${shellFlag}`);
100100
}
101101

102102
async modify(pc: ParameterChange<GithubCliAliasConfig>, plan: ModifyPlan<GithubCliAliasConfig>): Promise<void> {
@@ -112,7 +112,9 @@ export class GithubCliAliasResource extends Resource<GithubCliAliasConfig> {
112112

113113
async destroy(plan: DestroyPlan<GithubCliAliasConfig>): Promise<void> {
114114
const $ = getPty();
115-
await $.spawn(`gh alias delete ${plan.currentConfig.alias}`);
115+
const { status } = await $.spawnSafe('which gh');
116+
if (status === SpawnStatus.ERROR) return;
117+
await $.spawnSafe(`gh alias delete ${plan.currentConfig.alias}`);
116118
}
117119

118120
private parseAliasList(output: string): Array<{ alias: string; expansion: string; shell: boolean }> {

test/github-cli/github-cli.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ describe('GitHub CLI integration tests', async () => {
77
const pluginPath = path.resolve('./src/index.ts');
88

99
beforeAll(async () => {
10-
await PluginTester.uninstall(pluginPath, [{ type: 'github-cli' }]);
10+
const isInstalled = await testSpawn('which gh');
11+
if (isInstalled.status === SpawnStatus.SUCCESS) {
12+
await PluginTester.uninstall(pluginPath, [{ type: 'github-cli' }]);
13+
}
1114
}, 60_000);
1215

1316
it('Can install and uninstall GitHub CLI', { timeout: 300_000 }, async () => {

0 commit comments

Comments
 (0)