diff --git a/packages/truffle-core/lib/commands/watch.js b/packages/truffle-core/lib/commands/watch.js index d851bac266f..bba28a19068 100644 --- a/packages/truffle-core/lib/commands/watch.js +++ b/packages/truffle-core/lib/commands/watch.js @@ -1,4 +1,5 @@ const colors = require("colors"); +const commandExistsSync = require("command-exists").sync; const command = { command: "watch", @@ -22,6 +23,16 @@ const command = { /[\/\\]\./ // Ignore files prefixed with . ] }; + // Certain large codebases have trouble with the watch command. + // Installing watchman resolves some of these issues. + if (commandExistsSync("watchman")) { + watchOptions.watchman = true; + } else { + config.logger.log( + "If you have trouble using watch, try installing watchman." + ); + } + const watchCallback = filePath => { const displayPath = path.join( "./", diff --git a/packages/truffle-core/package.json b/packages/truffle-core/package.json index d284b25591a..3bcc1a30bb2 100644 --- a/packages/truffle-core/package.json +++ b/packages/truffle-core/package.json @@ -8,6 +8,7 @@ "async": "2.6.1", "chai": "4.1.2", "colors": "^1.1.2", + "command-exists": "^1.2.8", "configstore": "^4.0.0", "cpr": "^0.4.3", "debug": "^3.1.0",