12
12
namespace Sp \BowerBundle \Bower ;
13
13
14
14
use Doctrine \Common \Cache \Cache ;
15
+ use Sp \BowerBundle \Bower \Exception \CommandException ;
16
+ use Sp \BowerBundle \Bower \Exception \Error ;
15
17
use Sp \BowerBundle \Bower \Exception \FileNotFoundException ;
16
18
use Sp \BowerBundle \Bower \Exception \InvalidMappingException ;
17
19
use Sp \BowerBundle \Bower \Exception \MappingException ;
18
20
use Sp \BowerBundle \Bower \Exception \RuntimeException ;
19
21
use Sp \BowerBundle \Bower \Package \DependencyMapper ;
20
22
use Sp \BowerBundle \Bower \Package \DependencyMapperInterface ;
21
23
use Symfony \Component \EventDispatcher \EventDispatcher ;
24
+ use Symfony \Component \Process \Process ;
22
25
use Symfony \Component \Process \ProcessBuilder ;
23
26
24
27
/**
@@ -76,7 +79,7 @@ public function __construct($bowerPath = '/usr/bin/bower', Cache $dependencyCach
76
79
*/
77
80
public function install (ConfigurationInterface $ config , $ callback = null )
78
81
{
79
- $ result = $ this ->execCommand ($ config , 'install ' , $ callback );
82
+ $ result = $ this ->execCommand ($ config , array ( 'install ' ) , $ callback );
80
83
81
84
return $ result ->getProcess ()->getExitCode ();
82
85
}
@@ -92,11 +95,8 @@ public function install(ConfigurationInterface $config, $callback = null)
92
95
*/
93
96
public function createDependencyMappingCache (ConfigurationInterface $ config )
94
97
{
95
- $ result = $ this ->execCommand ($ config , array ('list ' , '--map ' ));
98
+ $ result = $ this ->execCommand ($ config , array ('list ' , '--json ' ));
96
99
$ output = $ result ->getProcess ()->getOutput ();
97
- if (strpos ($ output , 'error ' )) {
98
- throw new MappingException (sprintf ('An error occurred while creating dependency mapping. The error was %s. ' , $ output ));
99
- }
100
100
101
101
$ mapping = json_decode ($ output , true );
102
102
if (null === $ mapping ) {
@@ -187,7 +187,7 @@ private function createCacheKey(ConfigurationInterface $config)
187
187
* @param string|array $commands
188
188
* @param \Closure|string|array|null $callback
189
189
*
190
- * @throws Exception\RuntimeException
190
+ * @throws Exception\CommandException
191
191
* @return BowerResult
192
192
*/
193
193
private function execCommand (ConfigurationInterface $ config , $ commands , $ callback = null )
@@ -214,11 +214,7 @@ private function execCommand(ConfigurationInterface $config, $commands, $callbac
214
214
$ proc ->run ($ callback );
215
215
216
216
if (!$ proc ->isSuccessful ()) {
217
- throw new RuntimeException (sprintf (
218
- 'An error occurred while executing the command %s. The error was: "%s" ' ,
219
- $ proc ->getCommandLine (),
220
- trim ($ proc ->getErrorOutput ())
221
- ));
217
+ throw new CommandException ($ proc ->getCommandLine (),trim ($ proc ->getErrorOutput ()));
222
218
}
223
219
224
220
$ this ->eventDispatcher ->dispatch (BowerEvents::POST_EXEC , new BowerEvent ($ config , $ commands ));
0 commit comments