11import execa , { sync } from "execa"
2- import { join , resolve } from "path"
2+ import { join } from "path"
33import { createLogsMatcher } from "./matcher"
44
5+ const gatsbyBinLocation = join (
6+ GLOBAL_GATSBY_CLI_LOCATION ,
7+ `node_modules` ,
8+ `.bin` ,
9+ `gatsby`
10+ )
11+
512// Use as `GatsbyCLI.cwd('execution-folder').invoke('new', 'foo')`
613export const GatsbyCLI = {
714 from ( relativeCwd ) {
815 return {
916 invoke ( args ) {
1017 const NODE_ENV = args [ 0 ] === `develop` ? `development` : `production`
1118 try {
12- const results = sync (
13- resolve ( `./node_modules/.bin/gatsby` ) ,
14- [ ] . concat ( args ) ,
15- {
16- cwd : join ( __dirname , `../` , `./${ relativeCwd } ` ) ,
17- env : { NODE_ENV , CI : 1 , GATSBY_LOGGER : `ink` } ,
18- }
19- )
19+ const results = sync ( gatsbyBinLocation , [ ] . concat ( args ) , {
20+ cwd : join ( __dirname , `../` , `./${ relativeCwd } ` ) ,
21+ env : { NODE_ENV , CI : 1 , GATSBY_LOGGER : `ink` } ,
22+ } )
2023
2124 return [
2225 results . exitCode ,
@@ -32,14 +35,10 @@ export const GatsbyCLI = {
3235
3336 invokeAsync : ( args , onExit ) => {
3437 const NODE_ENV = args [ 0 ] === `develop` ? `development` : `production`
35- const res = execa (
36- resolve ( `./node_modules/.bin/gatsby` ) ,
37- [ ] . concat ( args ) ,
38- {
39- cwd : join ( __dirname , `../` , `./${ relativeCwd } ` ) ,
40- env : { NODE_ENV , CI : 1 , GATSBY_LOGGER : `ink` } ,
41- }
42- )
38+ const res = execa ( gatsbyBinLocation , [ ] . concat ( args ) , {
39+ cwd : join ( __dirname , `../` , `./${ relativeCwd } ` ) ,
40+ env : { NODE_ENV , CI : 1 , GATSBY_LOGGER : `ink` } ,
41+ } )
4342
4443 const logs = [ ]
4544 res . stdout . on ( "data" , data => {
0 commit comments