Commit e0558bc4 authored by Dan Abramov's avatar Dan Abramov Committed by GitHub
Browse files

Use a single script (#57)

It is easier to add more scripts later this way.
parent 4ae57e0a
No related merge requests found
Showing with 25 additions and 15 deletions
+25 -15
#!/usr/bin/env node
require('../scripts/build');
#!/usr/bin/env node
require('../scripts/eject');
#!/usr/bin/env node
var path = require('path');
var spawn = require('cross-spawn');
var script = process.argv[2];
var args = process.argv.slice(3);
switch (script) {
case 'build':
case 'start':
case 'eject':
spawn(
'node',
[path.resolve(__dirname, '..', 'scripts', script)].concat(args),
{stdio: 'inherit'}
);
break;
default:
console.log('Unknown script "' + script + '".');
console.log('Perhaps you need to update react-scripts?');
break;
}
#!/usr/bin/env node
require('../scripts/start');
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
"template" "template"
], ],
"bin": { "bin": {
"start-react-app": "./bin/start-react-app.js", "react-scripts": "./bin/react-scripts.js"
"build-react-app": "./bin/build-react-app.js",
"eject-react-app": "./bin/eject-react-app.js"
}, },
"dependencies": { "dependencies": {
"autoprefixer": "6.3.7", "autoprefixer": "6.3.7",
......
...@@ -36,9 +36,9 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi ...@@ -36,9 +36,9 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
console.log('Ejecting...'); console.log('Ejecting...');
console.log(); console.log();
var selfPath = path.join(__dirname, '..'); var selfPath = path.join(__dirname, '..');
var hostPath = path.join(selfPath, '..', '..'); var hostPath = path.join(selfPath, '..', '..');
var files = [ var files = [
path.join('config', 'babel.dev.js'), path.join('config', 'babel.dev.js'),
path.join('config', 'babel.prod.js'), path.join('config', 'babel.prod.js'),
...@@ -73,7 +73,6 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi ...@@ -73,7 +73,6 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
content = content.replace(/^\/\*\*(\*(?!\/)|[^*])*\*\//, '').trim() + '\n'; content = content.replace(/^\/\*\*(\*(?!\/)|[^*])*\*\//, '').trim() + '\n';
fs.writeFileSync(path.join(hostPath, file), content); fs.writeFileSync(path.join(hostPath, file), content);
}); });
console.log(); console.log();
var selfPackage = require(path.join(selfPath, 'package.json')); var selfPackage = require(path.join(selfPath, 'package.json'));
...@@ -109,5 +108,4 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi ...@@ -109,5 +108,4 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
console.log('Please consider sharing why you ejected in this survey:'); console.log('Please consider sharing why you ejected in this survey:');
console.log(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1'); console.log(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1');
console.log(); console.log();
}); });
...@@ -26,8 +26,7 @@ module.exports = function(hostPath, appName, verbose) { ...@@ -26,8 +26,7 @@ module.exports = function(hostPath, appName, verbose) {
// Setup the script rules // Setup the script rules
hostPackage.scripts = {}; hostPackage.scripts = {};
['start', 'build', 'eject'].forEach(function(command) { ['start', 'build', 'eject'].forEach(function(command) {
hostPackage.scripts[command] = hostPackage.scripts[command] = 'react-scripts ' + command;
command + '-react-app';
}); });
fs.writeFileSync( fs.writeFileSync(
...@@ -53,7 +52,7 @@ module.exports = function(hostPath, appName, verbose) { ...@@ -53,7 +52,7 @@ module.exports = function(hostPath, appName, verbose) {
copySync( copySync(
path.join(selfPath, 'template', filename), path.join(selfPath, 'template', filename),
path.join(hostPath, filename) path.join(hostPath, filename)
); );
}); });
// Run another npm install for react and react-dom // Run another npm install for react and react-dom
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment