mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-06-19 17:53:49 +08:00
ES6 syntax (#2213)
This commit is contained in:
committed by
Dan Abramov
parent
07c75aa5fd
commit
5f93bc4d55
11
packages/react-scripts/bin/react-scripts.js
vendored
11
packages/react-scripts/bin/react-scripts.js
vendored
@@ -10,16 +10,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var spawn = require('cross-spawn');
|
||||
var script = process.argv[2];
|
||||
var args = process.argv.slice(3);
|
||||
const spawn = require('cross-spawn');
|
||||
const script = process.argv[2];
|
||||
const args = process.argv.slice(3);
|
||||
|
||||
switch (script) {
|
||||
case 'build':
|
||||
case 'eject':
|
||||
case 'start':
|
||||
case 'test':
|
||||
var result = spawn.sync(
|
||||
case 'test': {
|
||||
const result = spawn.sync(
|
||||
'node',
|
||||
[require.resolve('../scripts/' + script)].concat(args),
|
||||
{ stdio: 'inherit' }
|
||||
@@ -42,6 +42,7 @@ switch (script) {
|
||||
}
|
||||
process.exit(result.status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log('Unknown script "' + script + '".');
|
||||
console.log('Perhaps you need to update react-scripts?');
|
||||
|
||||
12
packages/react-scripts/config/env.js
vendored
12
packages/react-scripts/config/env.js
vendored
@@ -10,10 +10,10 @@
|
||||
// @remove-on-eject-end
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var paths = require('./paths');
|
||||
const fs = require('fs');
|
||||
const paths = require('./paths');
|
||||
|
||||
var NODE_ENV = process.env.NODE_ENV;
|
||||
const NODE_ENV = process.env.NODE_ENV;
|
||||
if (!NODE_ENV) {
|
||||
throw new Error(
|
||||
'The NODE_ENV environment variable is required but was not specified.'
|
||||
@@ -22,9 +22,9 @@ if (!NODE_ENV) {
|
||||
|
||||
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
||||
var dotenvFiles = [
|
||||
paths.dotenv + '.' + NODE_ENV + '.local',
|
||||
paths.dotenv + '.' + NODE_ENV,
|
||||
paths.dotenv + '.local',
|
||||
`${paths.dotenv}.${NODE_ENV}.local`,
|
||||
`${paths.dotenv}.${NODE_ENV}`,
|
||||
`${paths.dotenv}.local`,
|
||||
paths.dotenv,
|
||||
];
|
||||
// Load environment variables from .env* files. Suppress warnings using silent
|
||||
|
||||
12
packages/react-scripts/config/paths.js
vendored
12
packages/react-scripts/config/paths.js
vendored
@@ -17,9 +17,7 @@ const url = require('url');
|
||||
// Make sure any symlinks in the project folder are resolved:
|
||||
// https://github.com/facebookincubator/create-react-app/issues/637
|
||||
const appDirectory = fs.realpathSync(process.cwd());
|
||||
function resolveApp(relativePath) {
|
||||
return path.resolve(appDirectory, relativePath);
|
||||
}
|
||||
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
|
||||
|
||||
// We support resolving modules according to `NODE_PATH`.
|
||||
// This lets you use absolute paths in imports inside large monorepos:
|
||||
@@ -55,9 +53,7 @@ function ensureSlash(path, needsSlash) {
|
||||
}
|
||||
}
|
||||
|
||||
function getPublicUrl(appPackageJson) {
|
||||
return envPublicUrl || require(appPackageJson).homepage;
|
||||
}
|
||||
const getPublicUrl = (appPackageJson) => envPublicUrl || require(appPackageJson).homepage;
|
||||
|
||||
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
||||
// "public path" at which the app is served.
|
||||
@@ -90,9 +86,7 @@ module.exports = {
|
||||
};
|
||||
|
||||
// @remove-on-eject-begin
|
||||
function resolveOwn(relativePath) {
|
||||
return path.resolve(__dirname, '..', relativePath);
|
||||
}
|
||||
const resolveOwn = (relativePath) => path.resolve(__dirname, '..', relativePath);
|
||||
|
||||
// config before eject: we're in ./node_modules/react-scripts/config/
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user