Skip to content

Commit cfaf633

Browse files
committed
facebookgh-1269: Enabling nested folder paths for project name
1 parent 94c912d commit cfaf633

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/create-react-app/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function createApp(name, verbose, version) {
105105
checkAppName(appName);
106106

107107
if (!pathExists.sync(name)) {
108-
fs.mkdirSync(root);
108+
createFolderPath(name);
109109
} else if (!isSafeToCreateProjectIn(root)) {
110110
console.log('The directory ' + chalk.green(name) + ' contains files that could conflict.');
111111
console.log('Try using a new directory name.');
@@ -136,6 +136,16 @@ function createApp(name, verbose, version) {
136136
run(root, appName, version, verbose, originalDirectory);
137137
}
138138

139+
function createFolderPath(path) {
140+
var projectPath = (path + "/");
141+
projectPath.replace(/(\w+)\//ig, function(i, dirName, index){
142+
var dirPath = path.substr(0, index + 1 + dirName.length);
143+
if (!pathExists.sync(dirPath)) {
144+
fs.mkdirSync(dirPath);
145+
}
146+
});
147+
}
148+
139149
function shouldUseYarn() {
140150
try {
141151
execSync('yarn --version', {stdio: 'ignore'});

0 commit comments

Comments
 (0)