Skip to content

Commit 1e06ec9

Browse files
shashkovdanilgaearon
authored andcommitted
ES6 syntax (facebook#2213)
1 parent be2378b commit 1e06ec9

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

bin/react-scripts.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
'use strict';
1212

13-
var spawn = require('cross-spawn');
14-
var script = process.argv[2];
15-
var args = process.argv.slice(3);
13+
const spawn = require('cross-spawn');
14+
const script = process.argv[2];
15+
const args = process.argv.slice(3);
1616

1717
switch (script) {
1818
case 'build':
1919
case 'eject':
2020
case 'start':
21-
case 'test':
22-
var result = spawn.sync(
21+
case 'test': {
22+
const result = spawn.sync(
2323
'node',
2424
[require.resolve('../scripts/' + script)].concat(args),
2525
{ stdio: 'inherit' }
@@ -42,6 +42,7 @@ switch (script) {
4242
}
4343
process.exit(result.status);
4444
break;
45+
}
4546
default:
4647
console.log('Unknown script "' + script + '".');
4748
console.log('Perhaps you need to update react-scripts?');

config/env.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
// @remove-on-eject-end
1111
'use strict';
1212

13-
var fs = require('fs');
14-
var paths = require('./paths');
13+
const fs = require('fs');
14+
const paths = require('./paths');
1515

16-
var NODE_ENV = process.env.NODE_ENV;
16+
const NODE_ENV = process.env.NODE_ENV;
1717
if (!NODE_ENV) {
1818
throw new Error(
1919
'The NODE_ENV environment variable is required but was not specified.'
@@ -22,9 +22,9 @@ if (!NODE_ENV) {
2222

2323
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
2424
var dotenvFiles = [
25-
paths.dotenv + '.' + NODE_ENV + '.local',
26-
paths.dotenv + '.' + NODE_ENV,
27-
paths.dotenv + '.local',
25+
`${paths.dotenv}.${NODE_ENV}.local`,
26+
`${paths.dotenv}.${NODE_ENV}`,
27+
`${paths.dotenv}.local`,
2828
paths.dotenv,
2929
];
3030
// Load environment variables from .env* files. Suppress warnings using silent

config/paths.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ const url = require('url');
1717
// Make sure any symlinks in the project folder are resolved:
1818
// https://github.com/facebookincubator/create-react-app/issues/637
1919
const appDirectory = fs.realpathSync(process.cwd());
20-
function resolveApp(relativePath) {
21-
return path.resolve(appDirectory, relativePath);
22-
}
20+
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
2321

2422
// We support resolving modules according to `NODE_PATH`.
2523
// This lets you use absolute paths in imports inside large monorepos:
@@ -55,9 +53,7 @@ function ensureSlash(path, needsSlash) {
5553
}
5654
}
5755

58-
function getPublicUrl(appPackageJson) {
59-
return envPublicUrl || require(appPackageJson).homepage;
60-
}
56+
const getPublicUrl = (appPackageJson) => envPublicUrl || require(appPackageJson).homepage;
6157

6258
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
6359
// "public path" at which the app is served.
@@ -90,9 +86,7 @@ module.exports = {
9086
};
9187

9288
// @remove-on-eject-begin
93-
function resolveOwn(relativePath) {
94-
return path.resolve(__dirname, '..', relativePath);
95-
}
89+
const resolveOwn = (relativePath) => path.resolve(__dirname, '..', relativePath);
9690

9791
// config before eject: we're in ./node_modules/react-scripts/config/
9892
module.exports = {

0 commit comments

Comments
 (0)