Skip to content

Commit

Permalink
Add file watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUltDev committed Jun 8, 2023
1 parent 3444894 commit ce0d8f8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/hooks/useShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ export function useShell(): ShellInstance {
const {cols, rows} = terminal;
terminal.loadAddon(addon);
shell.mount(startFiles);
// Start file watcher
let watchReady = false;
const watch = await shell.spawn('npx', ['chokidar-cli', '.']);
watch.output.pipeTo(new WritableStream({
write(data) {
if (watchReady) {
console.log('Change detected: ', data);
} else if (data.includes('Watching "."')) {
console.log('File watcher ready.');
watchReady = true;
}
}
}));
// Start shell
const jsh = await shell.spawn('jsh', {terminal: {cols, rows}});
// Setup git alias
Expand Down

0 comments on commit ce0d8f8

Please sign in to comment.