File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public function handle(): void
4646
4747 private function installDependencies (): self
4848 {
49- spin (
49+ $ result = spin (
5050 callback: function () {
5151 $ packageJsonPath = base_path ('package.json ' );
5252 $ contents = File::json ($ packageJsonPath );
@@ -63,13 +63,18 @@ private function installDependencies(): self
6363
6464 File::put ($ packageJsonPath , json_encode ($ contents , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ));
6565
66- Process::path (base_path ())->run ('npm install ' , function (string $ type , string $ buffer ) {
67- echo $ buffer ;
68- });
66+ return Process::path (base_path ())->run ('npm install ' );
6967 },
7068 message: 'Installing dependencies... '
7169 );
7270
71+ if ($ result ->failed ()) {
72+ $ this ->line ($ result ->errorOutput () ?: $ result ->output ());
73+ $ this ->components ->error ('Failed to install dependencies. You need to run "npm install" manually. ' );
74+
75+ return $ this ;
76+ }
77+
7378 $ this ->components ->info ('Installed dependencies ' );
7479
7580 return $ this ;
Original file line number Diff line number Diff line change @@ -174,6 +174,24 @@ public function boot(): void
174174PHP, $ this ->files ->get (app_path ('Providers/AppServiceProvider.php ' )));
175175 }
176176
177+ #[Test]
178+ public function it_shows_error_when_npm_install_fails_but_continues ()
179+ {
180+ Process::fake ([
181+ '* ' => Process::result (
182+ output: '' ,
183+ errorOutput: 'npm ERR! code ERESOLVE ' ,
184+ exitCode: 1 ,
185+ ),
186+ ]);
187+
188+ $ this
189+ ->artisan ('statamic:setup-cp-vite ' )
190+ ->expectsOutputToContain ('Failed to install dependencies ' )
191+ ->expectsOutputToContain ('npm ERR! code ERESOLVE ' )
192+ ->expectsOutputToContain ('Added cp:dev and cp:build scripts to package.json ' );
193+ }
194+
177195 private function makeNecessaryFiles (): void
178196 {
179197 $ this ->files ->put (app_path ('Providers/AppServiceProvider.php ' ), <<<'PHP'
You can’t perform that action at this time.
0 commit comments