Improve watcher timeout error message (fixes #5005)

Summary: Closes https://github.com/facebook/react-native/pull/5022

Reviewed By: svcscm

Differential Revision: D2793185

Pulled By: milend

fb-gh-sync-id: ec49d27d6e405924269a48f32cce401b1ce380f6
This commit is contained in:
wvengen 2015-12-30 08:18:45 -08:00 committed by facebook-github-bot-9
parent ac0b2df846
commit 2ab3fe921b
1 changed files with 14 additions and 5 deletions

View File

@ -96,11 +96,7 @@ function createWatcher(rootConfig) {
return new Promise(function(resolve, reject) {
const rejectTimeout = setTimeout(function() {
reject(new Error([
'Watcher took too long to load',
'Try running `watchman version` from your terminal',
'https://facebook.github.io/watchman/docs/troubleshooting.html',
].join('\n')));
reject(new Error(timeoutMessage(Watcher)));
}, MAX_WAIT_TIME);
watcher.once('ready', function() {
@ -111,4 +107,17 @@ function createWatcher(rootConfig) {
});
}
function timeoutMessage(Watcher) {
const lines = [
'Watcher took too long to load (' + Watcher.name + ')',
];
if (Watcher === sane.WatchmanWatcher) {
lines.push(
'Try running `watchman version` from your terminal',
'https://facebook.github.io/watchman/docs/troubleshooting.html',
);
}
return lines.join('\n');
}
module.exports = FileWatcher;