Skip to content

Commit 396d7b5

Browse files
committed
gh-1269: Added "fs-extra" and removed "path-exists"
1 parent cfaf633 commit 396d7b5

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

packages/create-react-app/index.js

+3-16
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-
createFolderPath(name);
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);
@@ -136,16 +133,6 @@ function createApp(name, verbose, version) {
136133
run(root, appName, version, verbose, originalDirectory);
137134
}
138135

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-
149136
function shouldUseYarn() {
150137
try {
151138
execSync('yarn --version', {stdio: 'ignore'});

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
}

0 commit comments

Comments
 (0)