@@ -7,24 +7,31 @@ import { detect, getCommand } from "@antfu/ni";
77import PackageJson from "@npmcli/package-json" ;
88import fse from "fs-extra" ;
99
10- const TO_IGNORE = [ ".github" , "scripts " , "yarn.lock" , "package.json" ] ;
10+ const TO_IGNORE = [ ".github" , "__scripts " , "yarn.lock" , "package.json" ] ;
1111
12- const { stderr, stdout, exitCode } = await execa (
13- "git" ,
14- [ "--no-pager" , "diff" , "--name-only" , "HEAD~1" ] ,
15- { cwd : process . cwd ( ) }
16- ) ;
12+ let examples = [ ] ;
1713
18- if ( exitCode !== 0 ) {
19- console . error ( stderr ) ;
20- process . exit ( exitCode ) ;
21- }
14+ if ( process . env . CI ) {
15+ const { stderr, stdout, exitCode } = await execa (
16+ "git" ,
17+ [ "--no-pager" , "diff" , "--name-only" , "HEAD~1" ] ,
18+ { cwd : process . cwd ( ) }
19+ ) ;
2220
23- const files = stdout . split ( "\n" ) ;
21+ if ( exitCode !== 0 ) {
22+ console . error ( stderr ) ;
23+ process . exit ( exitCode ) ;
24+ }
2425
25- const dirs = files . map ( ( f ) => f . split ( "/" ) . at ( 0 ) ) ;
26+ const files = stdout . split ( "\n" ) ;
2627
27- const examples = [ ...new Set ( dirs ) ] . filter ( ( d ) => ! TO_IGNORE . includes ( d ) ) ;
28+ const dirs = files . map ( ( f ) => f . split ( "/" ) . at ( 0 ) ) ;
29+
30+ examples = [ ...new Set ( dirs ) ] . filter ( ( d ) => ! TO_IGNORE . includes ( d ) ) ;
31+ } else {
32+ examples = await fse . readdir ( process . cwd ( ) ) ;
33+ examples = examples . filter ( ( d ) => ! TO_IGNORE . includes ( d ) ) ;
34+ }
2835
2936const list = new Intl . ListFormat ( "en" , { style : "long" , type : "conjunction" } ) ;
3037
0 commit comments