Skip to content

Commit

Permalink
Try catches the watchman startup - re: microsoft#1793
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed May 4, 2021
1 parent e8f2fd4 commit 953c994
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let currentProcess = null
// for the project which looks only at .ts and .md files in the repo.

// Startup watchman
client.command(["watch-project", process.cwd()], function (error, resp) {
function watcher(error, resp) {
if (error) {
console.error("Error initiating watch:", error)
return
Expand Down Expand Up @@ -115,7 +115,7 @@ client.command(["watch-project", process.cwd()], function (error, resp) {
}
}
})
})
}

// @ts-ignore
client.on("end", function () {
Expand Down Expand Up @@ -174,3 +174,16 @@ const runCommand = argString => {
}

const playCommand = (path, volume) => `afplay \"${path}\" -v ${volume}`

try {
client.command(["watch-project", process.cwd()], watcher)
} catch (error) {
const showError = process.env.DEBUG
const suffix = !showError ? "Run with DEBUG=* to see the error logs." : ""
// prettier-ignore
console.log(`Watchman failed to load, this is _OK_ but you will not get automatic builds of sub-projects like the tsconfig reference or playground. ` + suffix)

if (showError) {
console.error(error)
}
}

0 comments on commit 953c994

Please sign in to comment.