diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js index 7c9394ea371..f1765861ce5 100644 --- a/packages/create-react-app/index.js +++ b/packages/create-react-app/index.js @@ -105,7 +105,7 @@ function createApp(name, verbose, version) { checkAppName(appName); if (!pathExists.sync(name)) { - fs.mkdirSync(root); + createFolderPath(name); } else if (!isSafeToCreateProjectIn(root)) { console.log('The directory ' + chalk.green(name) + ' contains files that could conflict.'); console.log('Try using a new directory name.'); @@ -136,6 +136,16 @@ function createApp(name, verbose, version) { run(root, appName, version, verbose, originalDirectory); } +function createFolderPath(path) { + var projectPath = (path + "/"); + projectPath.replace(/(\w+)\//ig, function(i, dirName, index){ + var dirPath = path.substr(0, index + 1 + dirName.length); + if (!pathExists.sync(dirPath)) { + fs.mkdirSync(dirPath); + } + }); +} + function shouldUseYarn() { try { execSync('yarn --version', {stdio: 'ignore'});