Skip to content

Commit e8298ae

Browse files
committedJan 9, 2016
Tell users what's going on in postinstall
1 parent 6b98926 commit e8298ae

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed
 

‎npm-scripts/postinstall.js

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
var execSync = require('child_process').execSync
21
var stat = require('fs').stat
32

4-
function exec(command) {
5-
execSync(command, { stdio: [0, 1, 2] })
6-
}
7-
83
stat('lib', function (error, stat) {
9-
if (error || !stat.isDirectory())
10-
exec('npm run build')
4+
if (error || !stat.isDirectory()) {
5+
console.warn(
6+
'-'.repeat(79) + '\n' +
7+
'Built output not found. It looks like you might be attempting to install React\n' +
8+
'Router from GitHub. React Router sources need to be transpiled before use. We\n'+
9+
'will now make a best-efforts attempt to transpile the code. This will only work\n' +
10+
'if your development environment is set up appropriately.\n' +
11+
'-'.repeat(79)
12+
)
13+
14+
try {
15+
var execSync = require('child_process').execSync
16+
execSync('npm run build', { stdio: [ 0, 1, 2 ] })
17+
} catch (e) {
18+
console.error(
19+
'-'.repeat(79) + '\n' +
20+
'Failed to build React Router automatically. Please install React Router from\n' +
21+
'npm, or clone the repo locally and build the library manually.\n' +
22+
'-'.repeat(79)
23+
)
24+
throw(e)
25+
}
26+
}
1127
})

0 commit comments

Comments
 (0)
Please sign in to comment.