From bc32d59ad57acaddad4911c078a7d6b9997723d3 Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 12 Feb 2016 15:44:02 +1000 Subject: [PATCH 1/5] Added missing markdown references. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b5387b3..2c7fc43 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ * Available as [Composer] package [eloquent/composer-npm-bridge]. +[composer]: http://getcomposer.org/ +[eloquent/composer-npm-bridge]: https://packagist.org/packages/eloquent/composer-npm-bridge + ## Requirements * The `npm` executable must be available in PATH. From 35204c8b57c5d971bb528431b303b7905d2fa6f4 Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 12 Feb 2016 15:44:30 +1000 Subject: [PATCH 2/5] Fixed heading. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c7fc43..171f551 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ [current version]: https://packagist.org/packages/eloquent/composer-npm-bridge [version-image]: https://img.shields.io/packagist/v/eloquent/composer-npm-bridge.svg?style=flat-square "This project uses semantic versioning" -## Installation and documentation +## Installation * Available as [Composer] package [eloquent/composer-npm-bridge]. From a444c9493d10b853218693285434b7e64c38d07d Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 12 Feb 2016 15:45:16 +1000 Subject: [PATCH 3/5] Fixed usage instructions. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 171f551..f421d85 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ To utilize the *Composer NPM bridge*, simply add `eloquent/composer-npm-bridge` to the `require` section of the project's Composer configuration: - composer require eloquent/composer-npm-bridge:~2 + composer require eloquent/composer-npm-bridge:^3 NPM dependencies are specified via a [package.json] configuration file in the root directory of the Composer package. Source control should be configured to From 41a6a332c220c752a5b4506d20d5808cebeb17e6 Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Mon, 22 Feb 2016 11:19:59 +1000 Subject: [PATCH 4/5] Removed Isolator. Relates to #11. --- CHANGELOG.md | 6 +++ composer.json | 3 +- composer.lock | 89 +++++++----------------------------- src/NpmClient.php | 25 +++++----- test/suite/NpmClientTest.php | 37 +++++++-------- 5 files changed, 54 insertions(+), 106 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a62af76..bec78f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Composer NPM bridge changelog +## Next release + +- **[FIXED]** Fixed bug where Isolator was unable to be autoloaded ([#11]). + +[#11]: https://github.com/eloquent/composer-npm-bridge/issues/11 + ## 3.0.0 (2016-02-12) - **[BC BREAK]** Stripped down implementation, many public methods removed. diff --git a/composer.json b/composer.json index c983ee6..2f4d477 100644 --- a/composer.json +++ b/composer.json @@ -14,8 +14,7 @@ "type": "composer-plugin", "require": { "php": ">=5.3", - "composer-plugin-api": "^1", - "icecave/isolator": "^2|^3" + "composer-plugin-api": "^1" }, "require-dev": { "composer/composer": "dev-master", diff --git a/composer.lock b/composer.lock index 4640b8e..5303969 100644 --- a/composer.lock +++ b/composer.lock @@ -4,68 +4,9 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "34367a889d13a09ad984d190e5795898", - "content-hash": "60748e1cbbc9d988c9d9cea64b80bdf4", - "packages": [ - { - "name": "icecave/isolator", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/IcecaveStudios/isolator.git", - "reference": "8fad9e64c393238b01b359e01bd7f25dcdb818e4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/IcecaveStudios/isolator/zipball/8fad9e64c393238b01b359e01bd7f25dcdb818e4", - "reference": "8fad9e64c393238b01b359e01bd7f25dcdb818e4", - "shasum": "" - }, - "require": { - "php": ">=5.3" - }, - "require-dev": { - "icecave/archer": "~1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-develop": "3.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Icecave\\Isolator\\": "src" - }, - "files": [ - "src/register-autoloader.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "James Harris", - "email": "james.harris@icecave.com.au", - "homepage": "https://github.com/jmalloc" - } - ], - "description": "Dependency injection for global functions.", - "homepage": "https://github.com/IcecaveStudios/isolator", - "keywords": [ - "Double", - "fake", - "mock", - "phpunit", - "stub", - "test", - "unit" - ], - "time": "2015-03-27 05:04:19" - } - ], + "hash": "cf5c6bb6890a089cfa1b926c9ddf9965", + "content-hash": "d4fa4aeeb9c8c2b836114efc66f8690f", + "packages": [], "packages-dev": [ { "name": "composer/composer", @@ -73,12 +14,12 @@ "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "6d1ebba75e99b8c714112bc85e96591ee0fdf0b4" + "reference": "4c0e163977f8289288df7b37e0fd0469d3e8cbc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/6d1ebba75e99b8c714112bc85e96591ee0fdf0b4", - "reference": "6d1ebba75e99b8c714112bc85e96591ee0fdf0b4", + "url": "https://api.github.com/repos/composer/composer/zipball/4c0e163977f8289288df7b37e0fd0469d3e8cbc6", + "reference": "4c0e163977f8289288df7b37e0fd0469d3e8cbc6", "shasum": "" }, "require": { @@ -140,7 +81,7 @@ "dependency", "package" ], - "time": "2016-02-11 11:17:41" + "time": "2016-02-20 19:28:03" }, { "name": "composer/semver", @@ -590,22 +531,24 @@ }, { "name": "phpspec/prophecy", - "version": "v1.5.0", + "version": "v1.6.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7" + "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7", - "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3c91bdf81797d725b14cb62906f9a4ce44235972", + "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1" + "sebastian/comparator": "~1.1", + "sebastian/recursion-context": "~1.0" }, "require-dev": { "phpspec/phpspec": "~2.0" @@ -613,7 +556,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "1.5.x-dev" } }, "autoload": { @@ -646,7 +589,7 @@ "spy", "stub" ], - "time": "2015-08-13 10:07:40" + "time": "2016-02-15 07:46:21" }, { "name": "phpunit/php-code-coverage", diff --git a/src/NpmClient.php b/src/NpmClient.php index 0d10968..fa498c3 100644 --- a/src/NpmClient.php +++ b/src/NpmClient.php @@ -14,7 +14,6 @@ use Composer\Util\ProcessExecutor; use Eloquent\Composer\NpmBridge\Exception\NpmCommandFailedException; use Eloquent\Composer\NpmBridge\Exception\NpmNotFoundException; -use Icecave\Isolator\Isolator; use Symfony\Component\Process\ExecutableFinder; /** @@ -29,11 +28,7 @@ class NpmClient */ public static function create() { - return new self( - new ProcessExecutor(), - new ExecutableFinder(), - Isolator::get() - ); + return new self(new ProcessExecutor(), new ExecutableFinder()); } /** @@ -43,16 +38,19 @@ public static function create() * * @param ProcessExecutor $processExecutor The process executor to use. * @param ExecutableFinder $executableFinder The executable finder to use. - * @param Isolator $isolator The isolator to use. + * @param callable $getcwd The getcwd() implementation to use. + * @param callable $chdir The chdir() implementation to use. */ public function __construct( ProcessExecutor $processExecutor, ExecutableFinder $executableFinder, - Isolator $isolator + $getcwd = 'getcwd', + $chdir = 'chdir' ) { $this->processExecutor = $processExecutor; $this->executableFinder = $executableFinder; - $this->isolator = $isolator; + $this->getcwd = $getcwd; + $this->chdir = $chdir; } /** @@ -111,14 +109,14 @@ private function executeNpm($arguments, $workingDirectoryPath) $command = implode(' ', array_map('escapeshellarg', $arguments)); if (null !== $workingDirectoryPath) { - $previousWorkingDirectoryPath = $this->isolator->getcwd(); - $this->isolator->chdir($workingDirectoryPath); + $previousWorkingDirectoryPath = call_user_func($this->getcwd); + call_user_func($this->chdir, $workingDirectoryPath); } $exitCode = $this->processExecutor->execute($command); if (null !== $workingDirectoryPath) { - $this->isolator->chdir($previousWorkingDirectoryPath); + call_user_func($this->chdir, $previousWorkingDirectoryPath); } if (0 !== $exitCode) { @@ -141,6 +139,7 @@ private function npmPath() private $processExecutor; private $executableFinder; - private $isolator; + private $getcwd; + private $chdir; private $npmPath; } diff --git a/test/suite/NpmClientTest.php b/test/suite/NpmClientTest.php index 95f5b8c..6528378 100644 --- a/test/suite/NpmClientTest.php +++ b/test/suite/NpmClientTest.php @@ -22,13 +22,14 @@ protected function setUp() { $this->processExecutor = Phony::mock('Composer\Util\ProcessExecutor'); $this->executableFinder = Phony::mock('Symfony\Component\Process\ExecutableFinder'); - $this->isolator = Phony::mock('Icecave\Isolator\Isolator'); + $this->getcwd = Phony::stub(); + $this->chdir = Phony::stub(); $this->client = - new NpmClient($this->processExecutor->mock(), $this->executableFinder->mock(), $this->isolator->mock()); + new NpmClient($this->processExecutor->mock(), $this->executableFinder->mock(), $this->getcwd, $this->chdir); - $this->executableFinder->find('npm')->returns('/path/to/npm'); - $this->isolator->getcwd()->returns('/path/to/cwd'); $this->processExecutor->execute('*')->returns(0); + $this->executableFinder->find('npm')->returns('/path/to/npm'); + $this->getcwd->returns('/path/to/cwd'); } public function testInstall() @@ -37,12 +38,12 @@ public function testInstall() $this->assertNull($this->client->install('/path/to/project')); Phony::inOrder( $this->executableFinder->find->calledWith('npm'), - $this->isolator->chdir->calledWith('/path/to/project'), + $this->chdir->calledWith('/path/to/project'), $this->processExecutor->execute->calledWith("'/path/to/npm' 'install'"), - $this->isolator->chdir->calledWith('/path/to/cwd'), - $this->isolator->chdir->calledWith('/path/to/project'), + $this->chdir->calledWith('/path/to/cwd'), + $this->chdir->calledWith('/path/to/project'), $this->processExecutor->execute->calledWith("'/path/to/npm' 'install'"), - $this->isolator->chdir->calledWith('/path/to/cwd') + $this->chdir->calledWith('/path/to/cwd') ); } @@ -51,9 +52,9 @@ public function testInstallProductionMode() $this->assertNull($this->client->install('/path/to/project', false)); Phony::inOrder( $this->executableFinder->find->calledWith('npm'), - $this->isolator->chdir->calledWith('/path/to/project'), + $this->chdir->calledWith('/path/to/project'), $this->processExecutor->execute->calledWith("'/path/to/npm' 'install' '--production'"), - $this->isolator->chdir->calledWith('/path/to/cwd') + $this->chdir->calledWith('/path/to/cwd') ); } @@ -79,12 +80,12 @@ public function testUpdate() $this->assertNull($this->client->update('/path/to/project')); Phony::inOrder( $this->executableFinder->find->calledWith('npm'), - $this->isolator->chdir->calledWith('/path/to/project'), + $this->chdir->calledWith('/path/to/project'), $this->processExecutor->execute->calledWith("'/path/to/npm' 'update'"), - $this->isolator->chdir->calledWith('/path/to/cwd'), - $this->isolator->chdir->calledWith('/path/to/project'), + $this->chdir->calledWith('/path/to/cwd'), + $this->chdir->calledWith('/path/to/project'), $this->processExecutor->execute->calledWith("'/path/to/npm' 'update'"), - $this->isolator->chdir->calledWith('/path/to/cwd') + $this->chdir->calledWith('/path/to/cwd') ); } @@ -110,12 +111,12 @@ public function testShrinkwrap() $this->assertNull($this->client->shrinkwrap('/path/to/project')); Phony::inOrder( $this->executableFinder->find->calledWith('npm'), - $this->isolator->chdir->calledWith('/path/to/project'), + $this->chdir->calledWith('/path/to/project'), $this->processExecutor->execute->calledWith("'/path/to/npm' 'shrinkwrap'"), - $this->isolator->chdir->calledWith('/path/to/cwd'), - $this->isolator->chdir->calledWith('/path/to/project'), + $this->chdir->calledWith('/path/to/cwd'), + $this->chdir->calledWith('/path/to/project'), $this->processExecutor->execute->calledWith("'/path/to/npm' 'shrinkwrap'"), - $this->isolator->chdir->calledWith('/path/to/cwd') + $this->chdir->calledWith('/path/to/cwd') ); } From 2aebbe8d63557e969fa5d633d1bc55b5c953c9eb Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Mon, 22 Feb 2016 12:25:15 +1000 Subject: [PATCH 5/5] Version bump. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bec78f0..fa04cd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Composer NPM bridge changelog -## Next release +## 3.0.1 (2016-02-22) - **[FIXED]** Fixed bug where Isolator was unable to be autoloaded ([#11]).