Skip to content

Commit 8aff84b

Browse files
committed
Merge branch 'develop'
* develop: Return command results.
2 parents b31a08c + ea0254e commit 8aff84b

File tree

5 files changed

+79
-33
lines changed

5 files changed

+79
-33
lines changed

src/Commands/ClearOpCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public function digipolisClearOpCache(
2323
'host' => null,
2424
]
2525
) {
26-
$this->taskClearOpCache($environment, $opts['host'])->run();
26+
return $this->taskClearOpCache($environment, $opts['host'])->run();
2727
}
2828
}

src/Commands/PartialCleanDirs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function digipolisCleanDir($dirs, $opts = ['sort' => PartialCleanDirsTask
3030
}
3131
$dirsArg[] = $dirParts[0];
3232
}
33-
$this->taskPartialCleanDirs($dirsArg)
33+
return $this->taskPartialCleanDirs($dirsArg)
3434
->sortBy($opts['sort'])
3535
->run();
3636
}

src/Commands/PushPackage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function digipolisPushPackage(
3838
$auth = $opts['key-file']
3939
? new KeyFile($user, $opts['key-file'], $opts['password'])
4040
: new Password($user, $opts['password']);
41-
$this->taskPushPackage($host, $auth)
41+
return $this->taskPushPackage($host, $auth)
4242
->port($opts['port'])
4343
->timeout($opts['timeout'])
4444
->destinationFolder($destination)

src/PartialCleanDirs.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,12 @@ protected function cleanDir($dir, $keep)
240240
$finder->sort($this->sort);
241241
break;
242242
}
243-
foreach ($finder as $item) {
244-
if ($keep) {
245-
$keep--;
246-
continue;
247-
}
243+
$items = iterator_to_array($finder->getIterator());
244+
if ($keep) {
245+
array_splice($items, -$keep);
246+
}
247+
foreach ($items as $item) {
248+
$this->fs->chmod($item, 0777, 0000, true);
248249
$this->fs->remove($item);
249250
}
250251
}

tests/PartialCleanDirsTest.php

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,54 +75,99 @@ public function testRun() {
7575
->getMock();
7676

7777
$fs->expects($this->at(0))
78-
->method('remove')
79-
->with('dir6');
78+
->method('chmod')
79+
->with('dir1', 0777, 0000, true);
8080
$fs->expects($this->at(1))
8181
->method('remove')
82-
->with('dir7');
82+
->with('dir1');
8383
$fs->expects($this->at(2))
84-
->method('remove')
85-
->with('dir8');
84+
->method('chmod')
85+
->with('dir2', 0777, 0000, true);
8686
$fs->expects($this->at(3))
8787
->method('remove')
88-
->with('dir9');
88+
->with('dir2');
8989
$fs->expects($this->at(4))
90-
->method('remove')
91-
->with('dir10');
90+
->method('chmod')
91+
->with('dir3', 0777, 0000, true);
9292
$fs->expects($this->at(5))
9393
->method('remove')
94-
->with('dir11');
95-
96-
// Delete items in path/to/dir2.
94+
->with('dir3');
9795
$fs->expects($this->at(6))
98-
->method('remove')
99-
->with('dir4');
96+
->method('chmod')
97+
->with('dir4', 0777, 0000, true);
10098
$fs->expects($this->at(7))
10199
->method('remove')
102-
->with('dir5');
100+
->with('dir4');
103101
$fs->expects($this->at(8))
104-
->method('remove')
105-
->with('dir6');
102+
->method('chmod')
103+
->with('dir5', 0777, 0000, true);
106104
$fs->expects($this->at(9))
107105
->method('remove')
108-
->with('dir7');
106+
->with('dir5');
109107
$fs->expects($this->at(10))
110-
->method('remove')
111-
->with('dir8');
108+
->method('chmod')
109+
->with('dir6', 0777, 0000, true);
112110
$fs->expects($this->at(11))
113111
->method('remove')
114-
->with('dir9');
112+
->with('dir6');
113+
114+
// Delete items in path/to/dir2.
115115
$fs->expects($this->at(12))
116-
->method('remove')
117-
->with('dir10');
116+
->method('chmod')
117+
->with('dir1', 0777, 0000, true);
118118
$fs->expects($this->at(13))
119119
->method('remove')
120-
->with('dir11');
120+
->with('dir1');
121+
$fs->expects($this->at(14))
122+
->method('chmod')
123+
->with('dir2', 0777, 0000, true);
124+
$fs->expects($this->at(15))
125+
->method('remove')
126+
->with('dir2');
127+
$fs->expects($this->at(16))
128+
->method('chmod')
129+
->with('dir3', 0777, 0000, true);
130+
$fs->expects($this->at(17))
131+
->method('remove')
132+
->with('dir3');
133+
$fs->expects($this->at(18))
134+
->method('chmod')
135+
->with('dir4', 0777, 0000, true);
136+
$fs->expects($this->at(19))
137+
->method('remove')
138+
->with('dir4');
139+
$fs->expects($this->at(20))
140+
->method('chmod')
141+
->with('dir5', 0777, 0000, true);
142+
$fs->expects($this->at(21))
143+
->method('remove')
144+
->with('dir5');
145+
$fs->expects($this->at(22))
146+
->method('chmod')
147+
->with('dir6', 0777, 0000, true);
148+
$fs->expects($this->at(23))
149+
->method('remove')
150+
->with('dir6');
151+
$fs->expects($this->at(24))
152+
->method('chmod')
153+
->with('dir7', 0777, 0000, true);
154+
$fs->expects($this->at(25))
155+
->method('remove')
156+
->with('dir7');
157+
$fs->expects($this->at(26))
158+
->method('chmod')
159+
->with('dir8', 0777, 0000, true);
160+
$fs->expects($this->at(27))
161+
->method('remove')
162+
->with('dir8');
121163

122164
// Delete items in path/to/dir3.
123-
$fs->expects($this->at(14))
165+
$fs->expects($this->at(28))
166+
->method('chmod')
167+
->with('dir1', 0777, 0000, true);
168+
$fs->expects($this->at(29))
124169
->method('remove')
125-
->with('dir11');
170+
->with('dir1');
126171

127172
$result = $this->taskPartialCleanDirs($dirs, $finder, $fs)
128173
->run();

0 commit comments

Comments
 (0)