File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,17 @@ interface FileInfo {
2424 mode : number ;
2525}
2626
27- const PACK_CMD = [ "npm" , "pack" , "--dry-run" , "--json" ] ;
27+ const PACK_CMD = [
28+ "npm" ,
29+ "pack" ,
30+ // Don't create any package, we just need to see what would be packed.
31+ "--dry-run" ,
32+ // Prevents things like Husky from outputting to stdout, we don't need them
33+ // here anyway.
34+ "--ignore-scripts" ,
35+ // JSON is easier to parse and more stable between npm versions.
36+ "--json" ,
37+ ] ;
2838
2939/**
3040 * @param textOrLines
@@ -49,10 +59,16 @@ function runNpmPack(): PackageInfo[] {
4959 // from there doesn't exhibit those issues.
5060 execSync ( `${ PACK_CMD . join ( " " ) } > ${ tmpFile } ` , {
5161 encoding : "utf-8" ,
52- env : { ...process . env , LC_ALL : "C" } ,
62+ env : {
63+ ...process . env ,
64+ LC_ALL : "C" ,
65+ NODE_ENV : "production" ,
66+ } ,
5367 } ) ;
5468
55- const stdout = readFileSync ( tmpFile , "utf-8" ) ;
69+ const stdout = readFileSync ( tmpFile , "utf-8" )
70+ // TODO: Why doesn't --ignore-scripts turn Husky off? It works in CLI.
71+ . replace ( / ^ ( [ ^ [ ] * ) \[ \n / , "[" ) ;
5672
5773 try {
5874 return JSON . parse ( stdout ) ;
You can’t perform that action at this time.
0 commit comments