Skip to content

Commit 728c68c

Browse files
dinukadesilvaalexdriaguine
authored andcommitted
facebookgh-1269: Enabling nested folder paths for project name (facebook#1270)
* facebookgh-1269: Enabling nested folder paths for project name * facebookgh-1269: Added "fs-extra" and removed "path-exists" * facebookgh-1269: Added e2e test cases to verify nested folder names
1 parent afdbbac commit 728c68c

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

packages/create-react-app/index.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ if (currentNodeVersion.split('.')[0] < 4) {
5252
process.exit(1);
5353
}
5454

55-
var fs = require('fs');
55+
var fs = require('fs-extra');
5656
var path = require('path');
5757
var execSync = require('child_process').execSync;
5858
var spawn = require('cross-spawn');
5959
var semver = require('semver');
60-
var pathExists = require('path-exists');
6160

6261
var projectName;
6362

@@ -103,10 +102,8 @@ function createApp(name, verbose, version) {
103102
var appName = path.basename(root);
104103

105104
checkAppName(appName);
106-
107-
if (!pathExists.sync(name)) {
108-
fs.mkdirSync(root);
109-
} else if (!isSafeToCreateProjectIn(root)) {
105+
fs.ensureDirSync(name);
106+
if (!isSafeToCreateProjectIn(root)) {
110107
console.log('The directory ' + chalk.green(name) + ' contains files that could conflict.');
111108
console.log('Try using a new directory name.');
112109
process.exit(1);

packages/create-react-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"chalk": "^1.1.1",
2424
"commander": "^2.9.0",
2525
"cross-spawn": "^4.0.0",
26-
"path-exists": "^2.1.0",
26+
"fs-extra": "^1.0.0",
2727
"semver": "^5.0.3"
2828
}
2929
}

tasks/e2e.sh

+26
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,31 @@ cd test-app-fork
230230
# Check corresponding scripts version is installed.
231231
test -e node_modules/react-scripts-fork
232232

233+
# ******************************************************************************
234+
# Test nested folder path as the project name
235+
# ******************************************************************************
236+
237+
#Testing a path that exists
238+
cd $temp_app_path
239+
mkdir test-app-nested-paths-t1
240+
cd test-app-nested-paths-t1
241+
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
242+
create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
243+
cd test-app-nested-paths-t1/aa/bb/cc/dd
244+
npm start -- --smoke-test
245+
246+
#Testing a path that does not exist
247+
cd $temp_app_path
248+
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
249+
cd test-app-nested-paths-t2/aa/bb/cc/dd
250+
npm start -- --smoke-test
251+
252+
#Testing a path that is half exists
253+
cd $temp_app_path
254+
mkdir -p test-app-nested-paths-t3/aa
255+
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
256+
cd test-app-nested-paths-t3/aa/bb/cc/dd
257+
npm start -- --smoke-test
258+
233259
# Cleanup
234260
cleanup

0 commit comments

Comments
 (0)