deployer icon indicating copy to clipboard operation
deployer copied to clipboard

Deployer file not found when specified as CLI parameter on Windows

Open tfedor opened this issue 3 years ago • 0 comments

  • Deployer version: 7.0.0-rc2
  • Deployment OS: Windows

Deployer file not found when specified as CLI parameter on Windows, because the path is corrupted during loop.

Following line is meant to produce absolute path, but check for first slash fails on Windows. https://github.com/deployphp/deployer/blob/dddfab7b620eed8179c0f409402f219d2af598f6/bin/dep#L20

I'm not entirely sure why the absolute path is required, so I'm not pushing PR, but in my simple tests this was not needed.

However, possible solutions if absolute path is required might more robust check for absolute path, e.g. something simple as preg_match("#^/|[A-Z]:#", $deployFile), and I think it should only run once, maybe something like this:

    if (preg_match('/^(?:-f|--file)(?:=(?<file>.+?))?$/', $arg, $match)) {

        if (isset($match['file'])) {
            $deployFile = $match['file'];
        } elseif ($i + 1 < count($argv)) {
            $deployFile = $argv[$i + 1];
        }

        $deployFile = (preg_match("#^/|[A-Z]:#", $deployFile) ? '' : getcwd() . '/') . $deployFile;
    }

If you think this is a good solution and you want me to, I'll push a PR.

tfedor avatar Nov 21 '21 01:11 tfedor