Coder Social home page Coder Social logo

shell-command's Issues

Composer v2.0 readiness

Composer raises deprecation errors when installing the package. The main concern is that it states that some classes will no longer be autoloader when composer v2.0 hits.

Not critical, however, as they only look like test classes.

Deprecation Notice: Class ptlis\ShellCommand\Test\Mocks\MockProcessTest located in ./vendor/ptlis/shell-command/tests/Unit/Mocks/MockProcessTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 Deprecation Notice: Class ptlis\ShellCommand\Test\Mocks\MockCommandTest located in ./vendor/ptlis/shell-command/tests/Unit/Mocks/MockCommandTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 Deprecation Notice: Class ptlis\ShellCommand\Test\Mocks\MockCommandBuilderTest located in ./vendor/ptlis/shell-command/tests/Unit/Mocks/MockCommandBuilderTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 Deprecation Notice: Class ptlis\ShellCommand\Test\ProcessOutputTest located in ./vendor/ptlis/shell-command/tests/Unit/ProcessOutputTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.8/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

validateCommand() fails if CWD is set and process is ran in a different directory

Value set using setCwd() is not used in validateCommand(), so validation fails if relative command is not run in the same working directory.

How to test:

<?php
require __DIR__ . '/vendor/autoload.php';
$builder = (new \ptlis\ShellCommand\CommandBuilder())
        ->setCwd('/')
        ->setCommand('./bin/ls');
echo $builder->buildCommand();

This will succeed if called in /, but fail if script is called from any other directory:

PHP Fatal error:  Uncaught RuntimeException: Invalid command "./bin/ls" provided to ptlis\ShellCommand\CommandBuilder. in /app/vendor/ptlis/shell-command/src/CommandBuilder.php:180

Bug is in line 179 of CommandBuilder->buildCommand():

public function buildCommand(): CommandInterface
{
if (!$this->environment->validateCommand($this->command)) {
throw new \RuntimeException('Invalid command "' . $this->command . '" provided to ' . __CLASS__ . '.');
}

Hand-made patch:

-         if (!$this->environment->validateCommand($this->command) { 
+         if (!$this->environment->validateCommand($this->command, $this->cwd)) { 

Composer psr-4 Warning

Class ptlis\ShellCommand\Test\Mocks\MockCommandBuilderTest located in vendor/ptlis/shell-command/tests\Unit\Mocks\MockCommandBuilderTest.php does not comply with psr-4 autoloading standard. Skipping.

localhost > MAMP > PHP 8.1.0 + Composer 2.2.3

Feature Idea: Set working directory of command

Thanks for the package ๐Ÿ‘

I have a feature idea: It would be nice to have an option to change the working directory of a command.

This way an app could stay in the current working directory, but execute a binary from within another directory. This is often useful when running multiple tools which require different (relative oder absolute) entry points themself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.