Skip to content

gh-1269: Enabling nested folder paths for project name #1270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gh-1269: Added "fs-extra" and removed "path-exists"
  • Loading branch information
dinukadesilva committed Dec 17, 2016
commit 396d7b546673defbc07e41d54e7a0c4529554591
19 changes: 3 additions & 16 deletions packages/create-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ if (currentNodeVersion.split('.')[0] < 4) {
process.exit(1);
}

var fs = require('fs');
var fs = require('fs-extra');
var path = require('path');
var execSync = require('child_process').execSync;
var spawn = require('cross-spawn');
var semver = require('semver');
var pathExists = require('path-exists');

var projectName;

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

checkAppName(appName);

if (!pathExists.sync(name)) {
createFolderPath(name);
} else if (!isSafeToCreateProjectIn(root)) {
fs.ensureDirSync(name);
if (!isSafeToCreateProjectIn(root)) {
console.log('The directory ' + chalk.green(name) + ' contains files that could conflict.');
console.log('Try using a new directory name.');
process.exit(1);
Expand Down Expand Up @@ -136,16 +133,6 @@ 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
2 changes: 1 addition & 1 deletion packages/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"chalk": "^1.1.1",
"commander": "^2.9.0",
"cross-spawn": "^4.0.0",
"path-exists": "^2.1.0",
"fs-extra": "^1.0.0",
"semver": "^5.0.3"
}
}