Skip to content

Commit

Permalink
escape shell exec command args
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed May 26, 2022
1 parent 1f574b6 commit 1cc0b48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/create-docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 6 additions & 3 deletions packages/create-docusaurus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1cc0b48

Please sign in to comment.