@@ -10,6 +10,10 @@ import { dirname } from 'node:path'
1010import { execa } from 'execa'
1111
1212export type Environment = {
13+ startRun : ( ) => void
14+ finishRun : ( ) => void
15+ getErrors : ( ) => Array < string >
16+
1317 appendFile : ( path : string , contents : string ) => Promise < void >
1418 copyFile : ( from : string , to : string ) => Promise < void >
1519 writeFile : ( path : string , contents : string ) => Promise < void >
@@ -22,7 +26,14 @@ export type Environment = {
2226}
2327
2428export function createDefaultEnvironment ( ) : Environment {
29+ let errors : Array < string > = [ ]
2530 return {
31+ startRun : ( ) => {
32+ errors = [ ]
33+ } ,
34+ finishRun : ( ) => { } ,
35+ getErrors : ( ) => errors ,
36+
2637 appendFile : async ( path : string , contents : string ) => {
2738 await mkdir ( dirname ( path ) , { recursive : true } )
2839 return appendFile ( path , contents )
@@ -36,9 +47,15 @@ export function createDefaultEnvironment(): Environment {
3647 return writeFile ( path , contents )
3748 } ,
3849 execute : async ( command : string , args : Array < string > , cwd : string ) => {
39- await execa ( command , args , {
40- cwd,
41- } )
50+ try {
51+ await execa ( command , args , {
52+ cwd,
53+ } )
54+ } catch {
55+ errors . push (
56+ `Command "${ command } ${ args . join ( ' ' ) } " did not run successfully. Please run this manually in your project.` ,
57+ )
58+ }
4259 } ,
4360
4461 readFile : ( path : string , encoding ?: BufferEncoding ) =>
0 commit comments