Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit e0558bc

Browse files
authored
Use a single script (#57)
It is easier to add more scripts later this way.
1 parent 4ae57e0 commit e0558bc

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

bin/build-react-app.js

-2
This file was deleted.

bin/eject-react-app.js

-2
This file was deleted.

bin/react-scripts.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
var path = require('path');
3+
var spawn = require('cross-spawn');
4+
var script = process.argv[2];
5+
var args = process.argv.slice(3);
6+
7+
switch (script) {
8+
case 'build':
9+
case 'start':
10+
case 'eject':
11+
spawn(
12+
'node',
13+
[path.resolve(__dirname, '..', 'scripts', script)].concat(args),
14+
{stdio: 'inherit'}
15+
);
16+
break;
17+
default:
18+
console.log('Unknown script "' + script + '".');
19+
console.log('Perhaps you need to update react-scripts?');
20+
break;
21+
}

bin/start-react-app.js

-2
This file was deleted.

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
"template"
2222
],
2323
"bin": {
24-
"start-react-app": "./bin/start-react-app.js",
25-
"build-react-app": "./bin/build-react-app.js",
26-
"eject-react-app": "./bin/eject-react-app.js"
24+
"react-scripts": "./bin/react-scripts.js"
2725
},
2826
"dependencies": {
2927
"autoprefixer": "6.3.7",

scripts/eject.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
3636

3737
console.log('Ejecting...');
3838
console.log();
39+
3940
var selfPath = path.join(__dirname, '..');
4041
var hostPath = path.join(selfPath, '..', '..');
41-
4242
var files = [
4343
path.join('config', 'babel.dev.js'),
4444
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
7373
content = content.replace(/^\/\*\*(\*(?!\/)|[^*])*\*\//, '').trim() + '\n';
7474
fs.writeFileSync(path.join(hostPath, file), content);
7575
});
76-
7776
console.log();
7877

7978
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
109108
console.log('Please consider sharing why you ejected in this survey:');
110109
console.log(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1');
111110
console.log();
112-
113111
});

scripts/init.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ module.exports = function(hostPath, appName, verbose) {
2626
// Setup the script rules
2727
hostPackage.scripts = {};
2828
['start', 'build', 'eject'].forEach(function(command) {
29-
hostPackage.scripts[command] =
30-
command + '-react-app';
29+
hostPackage.scripts[command] = 'react-scripts ' + command;
3130
});
3231

3332
fs.writeFileSync(
@@ -53,7 +52,7 @@ module.exports = function(hostPath, appName, verbose) {
5352
copySync(
5453
path.join(selfPath, 'template', filename),
5554
path.join(hostPath, filename)
56-
);
55+
);
5756
});
5857

5958
// Run another npm install for react and react-dom

0 commit comments

Comments
 (0)