11import  {  ensureFile  }  from  '@neodx/fs' 
22import  {  hasOwn ,  isObject  }  from  '@neodx/std' 
33import  {  Inject  }  from  '@nestjs/common' 
4- import  chalk  from  'chalk' 
54import  {  Command ,  CommandRunner ,  Option  }  from  'nest-commander' 
65import  {  dirname ,  resolve  }  from  'node:path' 
76import  {  LoggerService  }  from  '@/logger' 
@@ -33,16 +32,13 @@ export class RunCommand extends CommandRunner {
3332
3433  public  async  run ( params : string [ ] ,  options : BaseInitOptions )  { 
3534    const  [ target ,  project  =  null ]  =  params 
36- 
37-     invariant ( target ,  'Target is not provided.' ) 
38- 
3935    const  timeEnd  =  this . logger . time ( ) 
40- 
4136    let  packageJsonPath  =  resolve ( process . cwd ( ) ,  'package.json' ) 
4237
38+     invariant ( target ,  'Target is not provided.' ) 
39+ 
4340    if  ( project )  { 
4441      const  workspaces  =  await  this . manager . getWorkspaces ( ) 
45- 
4642      const  projectMeta  =  workspaces . find ( 
4743        ( workspace )  =>  workspace . name  ===  project 
4844      ) 
@@ -58,12 +54,11 @@ export class RunCommand extends CommandRunner {
5854    await  ensureFile ( packageJsonPath ) 
5955
6056    const  pkg  =  await  readJson < PackageJson > ( packageJsonPath ) 
61- 
6257    const  projectName  =  project  ??  pkg . name  ??  'root' 
6358
6459    invariant ( 
6560      isObject ( pkg . scripts )  &&  hasOwn ( pkg . scripts ,  target ) , 
66-       `Could not find target ${ chalk . cyan ( target ) }   in project ${ chalk . white ( projectName ) }  .` 
61+       `Could not find target ${ target }   in project ${ projectName }  .` 
6762    ) 
6863
6964    const  command  =  this . manager . createRunCommand ( { 
@@ -86,6 +81,7 @@ export class RunCommand extends CommandRunner {
8681        `Error occurred while executing a command via ${ this . manager . agent }   agent.` 
8782      ) 
8883      this . logger . error ( error ) 
84+       return 
8985    } 
9086
9187    timeEnd ( `Successfully ran target ${ target }   for project ${ projectName }  ` ) 
0 commit comments