|
19 | 19 |
|
20 | 20 | class AssetPackageController extends \yii\console\Controller
|
21 | 21 | {
|
| 22 | + /** |
| 23 | + * @param string $type the package type. Can be either `bower` or `npm` |
| 24 | + * @param string $name the package name |
| 25 | + * @return boolean Whether the update was successful |
| 26 | + */ |
22 | 27 | public function actionUpdate($type, $name)
|
23 | 28 | {
|
24 | 29 | try {
|
25 | 30 | $package = new AssetPackage($type, $name);
|
26 | 31 | $package->update();
|
27 | 32 | echo 'updated ' . $package->getHash() . ' ' . $package->getFullName() . "\n";
|
| 33 | + return true; |
28 | 34 | } catch (\Exception $e) {
|
29 | 35 | echo Console::renderColoredString("%Rfailed%N $type/$name:%n {$e->getMessage()}\n");
|
| 36 | + return false; |
30 | 37 | }
|
31 | 38 | }
|
32 | 39 |
|
33 | 40 | public function actionUpdateList($file = STDIN)
|
34 | 41 | {
|
35 | 42 | $handler = is_resource($file) ? $file : fopen($file, 'r');
|
| 43 | + |
| 44 | + $errorPackages = []; |
| 45 | + |
36 | 46 | while ($line = fgets($handler)) {
|
37 | 47 | list($full) = preg_split('/\s+/', trim($line));
|
38 | 48 | list($type, $name) = AssetPackage::splitFullName($full);
|
39 |
| - $this->actionUpdate($type, $name); |
| 49 | + if (!$this->actionUpdate($type, $name)) { |
| 50 | + $errorPackages[] = $full; |
| 51 | + } |
40 | 52 | }
|
| 53 | + |
41 | 54 | if (!is_resource($file)) {
|
42 | 55 | fclose($handler);
|
43 | 56 | }
|
| 57 | + |
| 58 | + if (!empty($errorPackages)) { |
| 59 | + echo Console::renderColoredString("%RThe following packages were not updated due to unrecoverable errors:%n\n"); |
| 60 | + echo implode("\n", $errorPackages); |
| 61 | + } |
| 62 | + echo "\n"; |
44 | 63 | }
|
45 | 64 |
|
46 | 65 | public function actionUpdateAll()
|
|
0 commit comments