Skip to content

Commit 7b3efe7

Browse files
trevorlitseyfreiksenet
authored andcommitted
fix(gatsby-cli): create spawnWithArgs to be able to call spawn with command containing spaces (#14698)
1 parent 29e2de4 commit 7b3efe7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/gatsby-cli/src/init-starter.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const {
1717
const isTTY = require(`./util/is-tty`)
1818
const spawn = (cmd: string, options: any) => {
1919
const [file, ...args] = cmd.split(/\s+/)
20-
return execa(file, args, { stdio: `inherit`, ...options })
20+
return spawnWithArgs(file, args, options)
2121
}
22+
const spawnWithArgs = (file: string, args: string[], options: any) =>
23+
execa(file, args, { stdio: `inherit`, ...options })
2224

2325
// Checks the existence of yarn package and user preference if it exists
2426
// We use yarnpkg instead of yarn to avoid conflict with Hadoop yarn
@@ -152,11 +154,15 @@ const clone = async (hostInfo: any, rootPath: string) => {
152154
url = hostInfo.https({ noCommittish: true, noGitPlus: true })
153155
}
154156

155-
const branch = hostInfo.committish ? `-b ${hostInfo.committish}` : ``
157+
const branch = hostInfo.committish ? [`-b`, `hostInfo.committish`] : [``]
156158

157159
report.info(`Creating new site from git: ${url}`)
158160

159-
await spawn(`git clone ${branch} ${url} ${rootPath} --single-branch`)
161+
const args = [`clone`, ...branch, url, rootPath, `--single-branch`].filter(
162+
arg => Boolean(arg)
163+
)
164+
165+
await spawnWithArgs(`git`, args)
160166

161167
report.success(`Created starter directory layout`)
162168

0 commit comments

Comments
 (0)