@@ -7,24 +7,31 @@ import { detect, getCommand } from "@antfu/ni";
7
7
import PackageJson from "@npmcli/package-json" ;
8
8
import fse from "fs-extra" ;
9
9
10
- const TO_IGNORE = [ ".github" , "scripts " , "yarn.lock" , "package.json" ] ;
10
+ const TO_IGNORE = [ ".github" , "__scripts " , "yarn.lock" , "package.json" ] ;
11
11
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 = [ ] ;
17
13
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
+ ) ;
22
20
23
- const files = stdout . split ( "\n" ) ;
21
+ if ( exitCode !== 0 ) {
22
+ console . error ( stderr ) ;
23
+ process . exit ( exitCode ) ;
24
+ }
24
25
25
- const dirs = files . map ( ( f ) => f . split ( "/" ) . at ( 0 ) ) ;
26
+ const files = stdout . split ( "\n" ) ;
26
27
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
+ }
28
35
29
36
const list = new Intl . ListFormat ( "en" , { style : "long" , type : "conjunction" } ) ;
30
37
0 commit comments