Skip to content
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

ES6 syntax #2213

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 6 additions & 5 deletions packages/react-scripts/bin/react-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand All @@ -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?');
Expand Down
12 changes: 6 additions & 6 deletions packages/react-scripts/config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand All @@ -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
Expand Down
12 changes: 3 additions & 9 deletions packages/react-scripts/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 = {
Expand Down