Skip to content

Commit cc1e657

Browse files
tuchk4gaearon
authored andcommittedMar 7, 2017
update to modern code style (facebook#1738)
* mv create-react-app/index.js -> create-react-app/creteReactApp.js * update to modern code style * var -> cosnt * set trailing-coma to es5 for prettier
1 parent bda001c commit cc1e657

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1017
-843
lines changed
 

Diff for: ‎bin/react-scripts.js

+33-31
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,38 @@ var script = process.argv[2];
1515
var args = process.argv.slice(3);
1616

1717
switch (script) {
18-
case 'build':
19-
case 'eject':
20-
case 'start':
21-
case 'test':
22-
var result = spawn.sync(
23-
'node',
24-
[require.resolve('../scripts/' + script)].concat(args),
25-
{stdio: 'inherit'}
26-
);
27-
if (result.signal) {
28-
if (result.signal === 'SIGKILL') {
29-
console.log(
30-
'The build failed because the process exited too early. ' +
31-
'This probably means the system ran out of memory or someone called ' +
32-
'`kill -9` on the process.'
33-
);
34-
} else if (result.signal === 'SIGTERM') {
35-
console.log(
36-
'The build failed because the process exited too early. ' +
37-
'Someone might have called `kill` or `killall`, or the system could ' +
38-
'be shutting down.'
39-
);
18+
case 'build':
19+
case 'eject':
20+
case 'start':
21+
case 'test':
22+
var result = spawn.sync(
23+
'node',
24+
[require.resolve('../scripts/' + script)].concat(args),
25+
{ stdio: 'inherit' }
26+
);
27+
if (result.signal) {
28+
if (result.signal === 'SIGKILL') {
29+
console.log(
30+
'The build failed because the process exited too early. ' +
31+
'This probably means the system ran out of memory or someone called ' +
32+
'`kill -9` on the process.'
33+
);
34+
} else if (result.signal === 'SIGTERM') {
35+
console.log(
36+
'The build failed because the process exited too early. ' +
37+
'Someone might have called `kill` or `killall`, or the system could ' +
38+
'be shutting down.'
39+
);
40+
}
41+
process.exit(1);
4042
}
41-
process.exit(1);
42-
}
43-
process.exit(result.status);
44-
break;
45-
default:
46-
console.log('Unknown script "' + script + '".');
47-
console.log('Perhaps you need to update react-scripts?');
48-
console.log('See: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases');
49-
break;
43+
process.exit(result.status);
44+
break;
45+
default:
46+
console.log('Unknown script "' + script + '".');
47+
console.log('Perhaps you need to update react-scripts?');
48+
console.log(
49+
'See: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases'
50+
);
51+
break;
5052
}

Diff for: ‎config/env.js

+24-22
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,36 @@
1212

1313
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
1414
// injected into the application via DefinePlugin in Webpack configuration.
15-
16-
var REACT_APP = /^REACT_APP_/i;
15+
const REACT_APP = /^REACT_APP_/i;
1716

1817
function getClientEnvironment(publicUrl) {
19-
var raw = Object
20-
.keys(process.env)
18+
const raw = Object.keys(process.env)
2119
.filter(key => REACT_APP.test(key))
22-
.reduce((env, key) => {
23-
env[key] = process.env[key];
24-
return env;
25-
}, {
26-
// Useful for determining whether we’re running in production mode.
27-
// Most importantly, it switches React into the correct mode.
28-
'NODE_ENV': process.env.NODE_ENV || 'development',
29-
// Useful for resolving the correct path to static assets in `public`.
30-
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
31-
// This should only be used as an escape hatch. Normally you would put
32-
// images into the `src` and `import` them in code to get their paths.
33-
'PUBLIC_URL': publicUrl
34-
});
20+
.reduce(
21+
(env, key) => {
22+
env[key] = process.env[key];
23+
return env;
24+
},
25+
{
26+
// Useful for determining whether we’re running in production mode.
27+
// Most importantly, it switches React into the correct mode.
28+
NODE_ENV: process.env.NODE_ENV || 'development',
29+
// Useful for resolving the correct path to static assets in `public`.
30+
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
31+
// This should only be used as an escape hatch. Normally you would put
32+
// images into the `src` and `import` them in code to get their paths.
33+
PUBLIC_URL: publicUrl,
34+
}
35+
);
3536
// Stringify all values so we can feed into Webpack DefinePlugin
36-
var stringified = {
37-
'process.env': Object
38-
.keys(raw)
39-
.reduce((env, key) => {
37+
const stringified = {
38+
'process.env': Object.keys(raw).reduce(
39+
(env, key) => {
4040
env[key] = JSON.stringify(raw[key]);
4141
return env;
42-
}, {})
42+
},
43+
{}
44+
),
4345
};
4446

4547
return { raw, stringified };

0 commit comments

Comments
 (0)
Please sign in to comment.