@@ -9,6 +9,7 @@ const REPO_ROOT = path.resolve(__dirname, "..");
99const CLI_PATH = path . join ( REPO_ROOT , "bin" , "ling.js" ) ;
1010
1111function runCli ( args , options = { } ) {
12+ const allowedStatuses = options . allowedStatuses || [ 0 ] ;
1213 const env = {
1314 ...process . env ,
1415 LING_SKIP_UPSTREAM_CHECK : "1" ,
@@ -21,9 +22,11 @@ function runCli(args, options = {}) {
2122 encoding : "utf8" ,
2223 } ) ;
2324
24- if ( result . status !== 0 ) {
25+ if ( ! allowedStatuses . includes ( result . status ) ) {
2526 const message = result . stderr || result . stdout || "" ;
26- throw new Error ( `命令失败: ling ${ args . join ( " " ) } \n${ message } ` ) ;
27+ throw new Error (
28+ `命令失败: ling ${ args . join ( " " ) } \n(exit=${ result . status } )\n${ message } ` . trim ( ) ,
29+ ) ;
2730 }
2831
2932 return result . stdout || "" ;
@@ -82,7 +85,10 @@ function main() {
8285 throw new Error ( `spec status 结果异常: ${ specStatus } ` ) ;
8386 }
8487 runCli ( [ "spec" , "disable" , "--target" , "codex" , "--quiet" ] , { env } ) ;
85- const specStatusAfterDisable = runCli ( [ "spec" , "status" , "--quiet" ] , { env } ) . trim ( ) ;
88+ const specStatusAfterDisable = runCli ( [ "spec" , "status" , "--quiet" ] , {
89+ env,
90+ allowedStatuses : [ 0 , 2 ] ,
91+ } ) . trim ( ) ;
8692 if ( specStatusAfterDisable !== "missing" ) {
8793 throw new Error ( `spec disable 后状态异常: ${ specStatusAfterDisable } ` ) ;
8894 }
0 commit comments