Skip to content

refactor: replace which with direct command execution for cross-platform compatibility#141

Merged
dermatz merged 3 commits intofeature-magento-default-checksfrom
copilot/sub-pr-139-again
Feb 16, 2026
Merged

refactor: replace which with direct command execution for cross-platform compatibility#141
dermatz merged 3 commits intofeature-magento-default-checksfrom
copilot/sub-pr-139-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

The isCommandAvailable() method in NodePackageManager used the Unix/Linux-specific which command, causing failures on Windows systems.

Changes

  • Replace which <command> pattern with direct command execution using <command> --version 2>/dev/null
  • Aligns with existing cross-platform pattern used in CheckCommand::getNodeVersion() and CheckCommand::getNpmVersion()

Implementation

// Before
$this->shell->execute('which ' . $command . ' > /dev/null 2>&1');
return true;

// After
$output = trim($this->shell->execute($command . ' --version 2>/dev/null'));
return $output !== '';

This approach works because both npm and node support the --version flag, and the Shell service catches execution failures when commands don't exist.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: dermatz <6103201+dermatz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/magento/magento-coding-standard/zipball/f24dd98f46a98cd7081e4648b19299c27db35264
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/K3QUmM /usr/bin/composer create-project magento/magento-coding-standard --stability=dev /tmp/magento-coding-standard (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Refactor npm failure diagnostics based on review feedback refactor: replace which with direct command execution for cross-platform compatibility Feb 16, 2026
Copilot AI requested a review from dermatz February 16, 2026 21:37
@dermatz dermatz marked this pull request as ready for review February 16, 2026 21:39
Copilot AI review requested due to automatic review settings February 16, 2026 21:39
@dermatz dermatz enabled auto-merge (squash) February 16, 2026 21:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the isCommandAvailable() method in NodePackageManager to improve cross-platform compatibility by replacing the Unix/Linux-specific which command with direct command execution using the --version flag.

Changes:

  • Replaced which <command> pattern with <command> --version 2>/dev/null approach
  • Aligns with existing cross-platform pattern consistently used in CheckCommand methods

@dermatz dermatz disabled auto-merge February 16, 2026 21:47
@dermatz dermatz merged commit 7ed7197 into feature-magento-default-checks Feb 16, 2026
9 checks passed
@dermatz dermatz deleted the copilot/sub-pr-139-again branch February 16, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments