Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions plugin/core/devcontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ async function runCommand(cmd, args, options = {}) {
/**
* Check if the devcontainer CLI is installed
*
* @param {string} [platform] - Platform to check (defaults to process.platform)
* @returns {Promise<boolean>}
*/
export async function checkDevcontainerCli() {
export async function checkDevcontainerCli(platform = process.platform) {
try {
const result = await runCommand('which', ['devcontainer'])
const command = platform === 'win32' ? 'where' : 'which'
const result = await runCommand(command, ['devcontainer'])
return result.success
} catch {
return false
Expand Down
13 changes: 13 additions & 0 deletions test/unit/devcontainer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ describe('checkDevcontainerCli', () => {
const result = await checkDevcontainerCli()
assert.strictEqual(typeof result, 'boolean')
})

test('uses where command on win32', async () => {
// Note: 'where' command might not exist on non-Windows test environments (like Linux CI),
// which causes spawn to throw ENOENT instead of returning an exit code.
// Our checkDevcontainerCli function handles this gracefully with a try/catch, returning false.
const result = await checkDevcontainerCli('win32')
assert.strictEqual(typeof result, 'boolean')
})

test('uses which command on linux/darwin', async () => {
const result = await checkDevcontainerCli('linux')
assert.strictEqual(typeof result, 'boolean')
})
})

describe('list', () => {
Expand Down
Loading