Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Commit 8bcaa15

Browse files
committed
Merge branch 'release/3.0.1'
2 parents c9a4c52 + 2aebbe8 commit 8bcaa15

File tree

6 files changed

+59
-108
lines changed

6 files changed

+59
-108
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Composer NPM bridge changelog
22

3+
## 3.0.1 (2016-02-22)
4+
5+
- **[FIXED]** Fixed bug where Isolator was unable to be autoloaded ([#11]).
6+
7+
[#11]: https://github.com/eloquent/composer-npm-bridge/issues/11
8+
39
## 3.0.0 (2016-02-12)
410

511
- **[BC BREAK]** Stripped down implementation, many public methods removed.

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
[current version]: https://packagist.org/packages/eloquent/composer-npm-bridge
1414
[version-image]: https://img.shields.io/packagist/v/eloquent/composer-npm-bridge.svg?style=flat-square "This project uses semantic versioning"
1515

16-
## Installation and documentation
16+
## Installation
1717

1818
* Available as [Composer] package [eloquent/composer-npm-bridge].
1919

20+
[composer]: http://getcomposer.org/
21+
[eloquent/composer-npm-bridge]: https://packagist.org/packages/eloquent/composer-npm-bridge
22+
2023
## Requirements
2124

2225
* The `npm` executable must be available in PATH.
@@ -26,7 +29,7 @@
2629
To utilize the *Composer NPM bridge*, simply add `eloquent/composer-npm-bridge`
2730
to the `require` section of the project's Composer configuration:
2831

29-
composer require eloquent/composer-npm-bridge:~2
32+
composer require eloquent/composer-npm-bridge:^3
3033

3134
NPM dependencies are specified via a [package.json] configuration file in the
3235
root directory of the Composer package. Source control should be configured to

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"type": "composer-plugin",
1515
"require": {
1616
"php": ">=5.3",
17-
"composer-plugin-api": "^1",
18-
"icecave/isolator": "^2|^3"
17+
"composer-plugin-api": "^1"
1918
},
2019
"require-dev": {
2120
"composer/composer": "dev-master",

composer.lock

Lines changed: 16 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NpmClient.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Composer\Util\ProcessExecutor;
1515
use Eloquent\Composer\NpmBridge\Exception\NpmCommandFailedException;
1616
use Eloquent\Composer\NpmBridge\Exception\NpmNotFoundException;
17-
use Icecave\Isolator\Isolator;
1817
use Symfony\Component\Process\ExecutableFinder;
1918

2019
/**
@@ -29,11 +28,7 @@ class NpmClient
2928
*/
3029
public static function create()
3130
{
32-
return new self(
33-
new ProcessExecutor(),
34-
new ExecutableFinder(),
35-
Isolator::get()
36-
);
31+
return new self(new ProcessExecutor(), new ExecutableFinder());
3732
}
3833

3934
/**
@@ -43,16 +38,19 @@ public static function create()
4338
*
4439
* @param ProcessExecutor $processExecutor The process executor to use.
4540
* @param ExecutableFinder $executableFinder The executable finder to use.
46-
* @param Isolator $isolator The isolator to use.
41+
* @param callable $getcwd The getcwd() implementation to use.
42+
* @param callable $chdir The chdir() implementation to use.
4743
*/
4844
public function __construct(
4945
ProcessExecutor $processExecutor,
5046
ExecutableFinder $executableFinder,
51-
Isolator $isolator
47+
$getcwd = 'getcwd',
48+
$chdir = 'chdir'
5249
) {
5350
$this->processExecutor = $processExecutor;
5451
$this->executableFinder = $executableFinder;
55-
$this->isolator = $isolator;
52+
$this->getcwd = $getcwd;
53+
$this->chdir = $chdir;
5654
}
5755

5856
/**
@@ -111,14 +109,14 @@ private function executeNpm($arguments, $workingDirectoryPath)
111109
$command = implode(' ', array_map('escapeshellarg', $arguments));
112110

113111
if (null !== $workingDirectoryPath) {
114-
$previousWorkingDirectoryPath = $this->isolator->getcwd();
115-
$this->isolator->chdir($workingDirectoryPath);
112+
$previousWorkingDirectoryPath = call_user_func($this->getcwd);
113+
call_user_func($this->chdir, $workingDirectoryPath);
116114
}
117115

118116
$exitCode = $this->processExecutor->execute($command);
119117

120118
if (null !== $workingDirectoryPath) {
121-
$this->isolator->chdir($previousWorkingDirectoryPath);
119+
call_user_func($this->chdir, $previousWorkingDirectoryPath);
122120
}
123121

124122
if (0 !== $exitCode) {
@@ -141,6 +139,7 @@ private function npmPath()
141139

142140
private $processExecutor;
143141
private $executableFinder;
144-
private $isolator;
142+
private $getcwd;
143+
private $chdir;
145144
private $npmPath;
146145
}

test/suite/NpmClientTest.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ protected function setUp()
2222
{
2323
$this->processExecutor = Phony::mock('Composer\Util\ProcessExecutor');
2424
$this->executableFinder = Phony::mock('Symfony\Component\Process\ExecutableFinder');
25-
$this->isolator = Phony::mock('Icecave\Isolator\Isolator');
25+
$this->getcwd = Phony::stub();
26+
$this->chdir = Phony::stub();
2627
$this->client =
27-
new NpmClient($this->processExecutor->mock(), $this->executableFinder->mock(), $this->isolator->mock());
28+
new NpmClient($this->processExecutor->mock(), $this->executableFinder->mock(), $this->getcwd, $this->chdir);
2829

29-
$this->executableFinder->find('npm')->returns('/path/to/npm');
30-
$this->isolator->getcwd()->returns('/path/to/cwd');
3130
$this->processExecutor->execute('*')->returns(0);
31+
$this->executableFinder->find('npm')->returns('/path/to/npm');
32+
$this->getcwd->returns('/path/to/cwd');
3233
}
3334

3435
public function testInstall()
@@ -37,12 +38,12 @@ public function testInstall()
3738
$this->assertNull($this->client->install('/path/to/project'));
3839
Phony::inOrder(
3940
$this->executableFinder->find->calledWith('npm'),
40-
$this->isolator->chdir->calledWith('/path/to/project'),
41+
$this->chdir->calledWith('/path/to/project'),
4142
$this->processExecutor->execute->calledWith("'/path/to/npm' 'install'"),
42-
$this->isolator->chdir->calledWith('/path/to/cwd'),
43-
$this->isolator->chdir->calledWith('/path/to/project'),
43+
$this->chdir->calledWith('/path/to/cwd'),
44+
$this->chdir->calledWith('/path/to/project'),
4445
$this->processExecutor->execute->calledWith("'/path/to/npm' 'install'"),
45-
$this->isolator->chdir->calledWith('/path/to/cwd')
46+
$this->chdir->calledWith('/path/to/cwd')
4647
);
4748
}
4849

@@ -51,9 +52,9 @@ public function testInstallProductionMode()
5152
$this->assertNull($this->client->install('/path/to/project', false));
5253
Phony::inOrder(
5354
$this->executableFinder->find->calledWith('npm'),
54-
$this->isolator->chdir->calledWith('/path/to/project'),
55+
$this->chdir->calledWith('/path/to/project'),
5556
$this->processExecutor->execute->calledWith("'/path/to/npm' 'install' '--production'"),
56-
$this->isolator->chdir->calledWith('/path/to/cwd')
57+
$this->chdir->calledWith('/path/to/cwd')
5758
);
5859
}
5960

@@ -79,12 +80,12 @@ public function testUpdate()
7980
$this->assertNull($this->client->update('/path/to/project'));
8081
Phony::inOrder(
8182
$this->executableFinder->find->calledWith('npm'),
82-
$this->isolator->chdir->calledWith('/path/to/project'),
83+
$this->chdir->calledWith('/path/to/project'),
8384
$this->processExecutor->execute->calledWith("'/path/to/npm' 'update'"),
84-
$this->isolator->chdir->calledWith('/path/to/cwd'),
85-
$this->isolator->chdir->calledWith('/path/to/project'),
85+
$this->chdir->calledWith('/path/to/cwd'),
86+
$this->chdir->calledWith('/path/to/project'),
8687
$this->processExecutor->execute->calledWith("'/path/to/npm' 'update'"),
87-
$this->isolator->chdir->calledWith('/path/to/cwd')
88+
$this->chdir->calledWith('/path/to/cwd')
8889
);
8990
}
9091

@@ -110,12 +111,12 @@ public function testShrinkwrap()
110111
$this->assertNull($this->client->shrinkwrap('/path/to/project'));
111112
Phony::inOrder(
112113
$this->executableFinder->find->calledWith('npm'),
113-
$this->isolator->chdir->calledWith('/path/to/project'),
114+
$this->chdir->calledWith('/path/to/project'),
114115
$this->processExecutor->execute->calledWith("'/path/to/npm' 'shrinkwrap'"),
115-
$this->isolator->chdir->calledWith('/path/to/cwd'),
116-
$this->isolator->chdir->calledWith('/path/to/project'),
116+
$this->chdir->calledWith('/path/to/cwd'),
117+
$this->chdir->calledWith('/path/to/project'),
117118
$this->processExecutor->execute->calledWith("'/path/to/npm' 'shrinkwrap'"),
118-
$this->isolator->chdir->calledWith('/path/to/cwd')
119+
$this->chdir->calledWith('/path/to/cwd')
119120
);
120121
}
121122

0 commit comments

Comments
 (0)