Skip to content

Commit

Permalink
Fix being able to use rs to restart processes
Browse files Browse the repository at this point in the history
fixes #74
  • Loading branch information
M-Zuber committed Mar 15, 2021
1 parent dc37969 commit bdf6313
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ EOF

Tests run *perfectly*, ship it to the enterprise!

Once you have the watcher running, you can force restart all tasks by entering `rs`.
If you want to only force a single task, type the name of the key from the watch config (for example `rs test`).

### Options

#### `patterns`
Expand Down
22 changes: 15 additions & 7 deletions watch-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,26 @@ module.exports = function watchPackage(_pkgDir, exit, taskName) {
// send 'rs' commands to the right proc
stdin = through(function (line, _, callback) {
line = line.toString()
var match = line.match(/^rs\s+(\w+)/)
var match = line.match(/^rs\s*(.*)/)
if (!match) {
console.log('Unrecognized input:', line)
return callback()
}
var proc = processes[match[1]]
if (!proc) {
console.log('Couldn\'t find process:', match[1])
return callback()

if (match[1]) {
var proc = processes[match[1]]
if (!proc) {
console.log('Couldn\'t find process:', match[1])
return callback()
}
proc.stdin.write('rs\r\n')
return callback();
} else {
Object.keys(processes).forEach(function (key) {
processes[key].stdin.write('rs\r\n')
})
callback()
}
proc.stdin.write('rs\n')
callback()
})

stdin.stderr = through()
Expand Down

0 comments on commit bdf6313

Please sign in to comment.