diff --git a/plugin/core/devcontainer.js b/plugin/core/devcontainer.js index a46b4d6..7aedbf6 100644 --- a/plugin/core/devcontainer.js +++ b/plugin/core/devcontainer.js @@ -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} */ -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 diff --git a/test/unit/devcontainer.test.js b/test/unit/devcontainer.test.js index 0d07b4a..94b5cbf 100644 --- a/test/unit/devcontainer.test.js +++ b/test/unit/devcontainer.test.js @@ -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', () => {