Skip to content

Commit

Permalink
gh-1269: Enabling nested folder paths for project name
Browse files Browse the repository at this point in the history
  • Loading branch information
dinukadesilva committed Dec 14, 2016
1 parent 94c912d commit cfaf633
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/create-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down Expand Up @@ -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'});
Expand Down

0 comments on commit cfaf633

Please sign in to comment.