Skip to content

Commit d81bae5

Browse files
committed
pwsh on windwows
1 parent 8ad7954 commit d81bae5

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,23 @@ jobs:
3434
run: pnpm install
3535

3636
- name: Run core tests (excluding shell integration)
37-
run: pnpm test --exclude="**/shell-integration.test.ts"
37+
run: pnpm vitest run --exclude "**/shell-integration.test.ts"
3838

3939
shell-tests:
4040
name: Shell Tests (${{ matrix.shell }} on ${{ matrix.os }})
4141
strategy:
4242
matrix:
4343
shell: [bash, zsh, fish, powershell]
44-
os: [ubuntu-latest, macos-latest]
44+
os: [ubuntu-latest, macos-latest, windows-latest]
4545
exclude:
4646
# PowerShell installation can be flaky on macOS in CI
4747
- shell: powershell
4848
os: macos-latest
49+
# Some shells are not easily available on Windows
50+
- shell: zsh
51+
os: windows-latest
52+
- shell: fish
53+
os: windows-latest
4954
runs-on: ${{ matrix.os }}
5055

5156
steps:
@@ -94,7 +99,30 @@ jobs:
9499
;;
95100
esac
96101
97-
- name: Verify shell installation
102+
- name: Install shell dependencies (Windows)
103+
if: matrix.os == 'windows-latest'
104+
shell: pwsh
105+
run: |
106+
# Windows specific shell setup
107+
switch ("${{ matrix.shell }}") {
108+
"bash" {
109+
# Git for Windows includes bash
110+
if (!(Get-Command git -ErrorAction SilentlyContinue)) {
111+
choco install git -y
112+
}
113+
Write-Host "Bash available via Git for Windows"
114+
}
115+
"powershell" {
116+
# PowerShell is already installed on Windows
117+
Write-Host "PowerShell already available"
118+
}
119+
default {
120+
Write-Host "Shell ${{ matrix.shell }} not supported on Windows"
121+
}
122+
}
123+
124+
- name: Verify shell installation (Unix)
125+
if: matrix.os != 'windows-latest'
98126
run: |
99127
case "${{ matrix.shell }}" in
100128
bash)
@@ -111,6 +139,22 @@ jobs:
111139
;;
112140
esac
113141
142+
- name: Verify shell installation (Windows)
143+
if: matrix.os == 'windows-latest'
144+
shell: pwsh
145+
run: |
146+
switch ("${{ matrix.shell }}") {
147+
"bash" {
148+
bash --version
149+
}
150+
"powershell" {
151+
pwsh --version
152+
}
153+
default {
154+
Write-Host "Verification not needed for ${{ matrix.shell }} on Windows"
155+
}
156+
}
157+
114158
- name: Install pnpm
115159
uses: pnpm/[email protected]
116160

tests/shell-integration.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,34 @@ Then source the completion in your shell profile:
201201
expect(stdout).toMatch(/complete -c \w+ -f/);
202202
});
203203
break;
204+
205+
case 'powershell':
206+
it('powershell completion should include proper functions', async () => {
207+
const command = `pnpm tsx examples/demo.${cliTool}.ts complete powershell`;
208+
const { stdout } = await exec(command);
209+
210+
// Should contain PowerShell function definition
211+
expect(stdout).toContain('function __');
212+
213+
// Should contain Register-ArgumentCompleter
214+
expect(stdout).toContain('Register-ArgumentCompleter');
215+
216+
// Should handle PowerShell completion parameters
217+
expect(stdout).toContain('$WordToComplete');
218+
expect(stdout).toContain('$CommandAst');
219+
expect(stdout).toContain('$CursorPosition');
220+
});
221+
break;
222+
223+
default:
224+
// For shells without specific tests, add a basic test to avoid empty suites
225+
it(`should generate ${shell} completion script`, async () => {
226+
const command = `pnpm tsx examples/demo.${cliTool}.ts complete ${shell}`;
227+
const { stdout } = await exec(command);
228+
expect(stdout).toBeTruthy();
229+
expect(stdout).toContain(`# ${shell} completion for`);
230+
});
231+
break;
204232
}
205233
});
206234
});

0 commit comments

Comments
 (0)