diff --git a/packages/create-docusaurus/package.json b/packages/create-docusaurus/package.json index 46ae2253e1b4..f4ca79dcd026 100755 --- a/packages/create-docusaurus/package.json +++ b/packages/create-docusaurus/package.json @@ -23,6 +23,7 @@ "license": "MIT", "dependencies": { "@docusaurus/logger": "2.0.0-beta.20", + "@docusaurus/utils": "2.0.0-beta.20", "commander": "^5.1.0", "fs-extra": "^10.1.0", "lodash": "^4.17.21", diff --git a/packages/create-docusaurus/src/index.ts b/packages/create-docusaurus/src/index.ts index 27d53f50fd59..b996c3e90b6b 100755 --- a/packages/create-docusaurus/src/index.ts +++ b/packages/create-docusaurus/src/index.ts @@ -13,6 +13,7 @@ import logger from '@docusaurus/logger'; import shell from 'shelljs'; import prompts, {type Choice} from 'prompts'; import supportsColor from 'supports-color'; +import {escapeShellArg} from '@docusaurus/utils'; type CLIOptions = { packageManager?: PackageManager; @@ -463,9 +464,11 @@ export default async function init( logger.info('Creating new Docusaurus project...'); if (source.type === 'git') { - logger.info`Cloning Git template url=${source.url}...`; - const command = await getGitCommand(source.strategy); - if (shell.exec(`${command} ${source.url} ${dest}`).code !== 0) { + const gitCommand = await getGitCommand(source.strategy); + const gitCloneCommand = `${gitCommand} ${escapeShellArg( + source.url, + )} ${escapeShellArg(dest)}`; + if (shell.exec(gitCloneCommand).code !== 0) { logger.error`Cloning Git template failed!`; process.exit(1); }