Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit aac319f

Browse files
author
Will Monk
committed
Merge remote-tracking branch 'fb/master'
2 parents e356e04 + 21b0044 commit aac319f

File tree

11 files changed

+63
-26
lines changed

11 files changed

+63
-26
lines changed

packages/create-react-app/index.js

Lines changed: 3 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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
}

packages/react-scripts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"jest": "17.0.2",
4242
"json-loader": "0.5.4",
4343
"object-assign": "4.1.0",
44-
"path-exists": "2.1.0",
4544
"postcss-loader": "1.0.0",
4645
"promise": "7.1.1",
4746
"react-dev-utils": "^0.4.2",

packages/react-scripts/scripts/build.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ require('dotenv').config({silent: true});
2121
var chalk = require('chalk');
2222
var fs = require('fs-extra');
2323
var path = require('path');
24-
var pathExists = require('path-exists');
2524
var filesize = require('filesize');
2625
var gzipSize = require('gzip-size').sync;
2726
var webpack = require('webpack');
@@ -31,7 +30,7 @@ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
3130
var recursive = require('recursive-readdir');
3231
var stripAnsi = require('strip-ansi');
3332

34-
var useYarn = pathExists.sync(paths.yarnLockFile);
33+
var useYarn = fs.existsSync(paths.yarnLockFile);
3534

3635
// Warn and crash if required files are missing
3736
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {

packages/react-scripts/scripts/eject.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
var createJestConfig = require('../utils/createJestConfig');
1111
var fs = require('fs-extra');
1212
var path = require('path');
13-
var pathExists = require('path-exists');
1413
var paths = require('../config/paths');
1514
var prompt = require('react-dev-utils/prompt');
1615
var spawnSync = require('cross-spawn').sync;
@@ -133,7 +132,7 @@ prompt(
133132
);
134133
console.log();
135134

136-
if (pathExists.sync(paths.yarnLockFile)) {
135+
if (fs.existsSync(paths.yarnLockFile)) {
137136
console.log(cyan('Running yarn...'));
138137
fs.removeSync(ownPath);
139138
spawnSync('yarn', [], {stdio: 'inherit'});

packages/react-scripts/scripts/init.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
var fs = require('fs-extra');
1111
var path = require('path');
1212
var spawn = require('cross-spawn');
13-
var pathExists = require('path-exists');
1413
var chalk = require('chalk');
1514

1615
module.exports = function(appPath, appName, verbose, originalDirectory) {
1716
var ownPackageName = require(path.join(__dirname, '..', 'package.json')).name;
1817
var ownPath = path.join(appPath, 'node_modules', ownPackageName);
1918
var appPackage = require(path.join(appPath, 'package.json'));
20-
var useYarn = pathExists.sync(path.join(appPath, 'yarn.lock'));
19+
var useYarn = fs.existsSync(path.join(appPath, 'yarn.lock'));
2120

2221
// Copy over some of the devDependencies
2322
appPackage.dependencies = appPackage.dependencies || {};
@@ -36,7 +35,7 @@ module.exports = function(appPath, appName, verbose, originalDirectory) {
3635
JSON.stringify(appPackage, null, 2)
3736
);
3837

39-
var readmeExists = pathExists.sync(path.join(appPath, 'README.md'));
38+
var readmeExists = fs.existsSync(path.join(appPath, 'README.md'));
4039
if (readmeExists) {
4140
fs.renameSync(path.join(appPath, 'README.md'), path.join(appPath, 'README.old.md'));
4241
}

packages/react-scripts/scripts/start.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
2929
var getProcessForPort = require('react-dev-utils/getProcessForPort');
3030
var openBrowser = require('react-dev-utils/openBrowser');
3131
var prompt = require('react-dev-utils/prompt');
32-
var pathExists = require('path-exists');
32+
var fs = require('fs');
3333
var config = require('../config/webpack.config.dev');
3434
var paths = require('../config/paths');
3535

36-
var useYarn = pathExists.sync(paths.yarnLockFile);
36+
var useYarn = fs.existsSync(paths.yarnLockFile);
3737
var cli = useYarn ? 'yarn' : 'npm';
3838
var isInteractive = process.stdout.isTTY;
3939

@@ -286,9 +286,7 @@ function runDevServer(host, port, protocol) {
286286
console.log(chalk.cyan('Starting the development server...'));
287287
console.log();
288288

289-
if (isInteractive) {
290-
openBrowser(protocol + '://' + host + ':' + port + '/');
291-
}
289+
openBrowser(protocol + '://' + host + ':' + port + '/');
292290
});
293291
}
294292

packages/react-scripts/template/README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
6464
- [Troubleshooting](#troubleshooting)
6565
- [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra)
6666
- [`npm run build` silently fails](#npm-run-build-silently-fails)
67+
- [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku)
6768
- [Something Missing?](#something-missing)
6869

6970
## Updating to New Releases
@@ -1171,7 +1172,21 @@ GitHub Pages doesn't support routers that use the HTML5 `pushState` history API
11711172
### Heroku
11721173
11731174
Use the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).<br>
1174-
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
1175+
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
1176+
1177+
#### Resolving "Module not found: Error: Cannot resolve 'file' or 'directory'"
1178+
1179+
Sometimes `npm run build` works locally but fails during deploy via Heroku with an error like this:
1180+
1181+
```
1182+
remote: Failed to create a production build. Reason:
1183+
remote: Module not found: Error: Cannot resolve 'file' or 'directory'
1184+
MyDirectory in /tmp/build_1234/src
1185+
```
1186+
1187+
This means you need to ensure that the lettercase of the file or directory you `import` matches the one you see on your filesystem or on GitHub.
1188+
1189+
This is important because Linux (the operating system used by Heroku) is case sensitive. So `MyDirectory` and `mydirectory` are two distinct directories and thus, even though the project builds locally, the difference in case breaks the `import` statements on Heroku remotes.
11751190
11761191
### Modulus
11771192
@@ -1265,6 +1280,11 @@ There are also reports that *uninstalling* Watchman fixes the issue. So if nothi
12651280
12661281
It is reported that `npm run build` can fail on machines with no swap space, which is common in cloud environments. If [the symptoms are matching](https://github.com/facebookincubator/create-react-app/issues/1133#issuecomment-264612171), consider adding some swap space to the machine you’re building on, or build the project locally.
12671282
1283+
### `npm run build` fails on Heroku
1284+
1285+
This may be a problem with case sensitive filenames.
1286+
Please refer to [this section](#resolving-module-not-found-error-cannot-resolve-file-or-directory).
1287+
12681288
## Something Missing?
12691289
12701290
If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md)

packages/react-scripts/template/gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

33
# dependencies
4-
node_modules
4+
/node_modules
55

66
# testing
7-
coverage
7+
/coverage
88

99
# production
10-
build
10+
/build
1111

1212
# misc
1313
.DS_Store

packages/react-scripts/utils/createJestConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
// Note: this file does not exist after ejecting.
1111

12-
const pathExists = require('path-exists');
12+
const fs = require('fs');
1313
const paths = require('../config/paths');
1414

1515
module.exports = (resolve, rootDir, isEjecting) => {
1616
// Use this instead of `paths.testsSetup` to avoid putting
1717
// an absolute filename into configuration after ejecting.
18-
const setupTestsFile = pathExists.sync(paths.testsSetup) ? '<rootDir>/src/setupTests.js' : undefined;
18+
const setupTestsFile = fs.existsSync(paths.testsSetup) ? '<rootDir>/src/setupTests.js' : undefined;
1919

2020
// TODO: I don't know if it's safe or not to just use / as path separator
2121
// in Jest configs. We need help from somebody with Windows to determine this.

tasks/e2e.sh

Lines changed: 26 additions & 0 deletions
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)