-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efd562c
commit a21fb86
Showing
5 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const exec = require('child_process').exec; | ||
const p = (...args) => path.resolve.apply(path.resolve, [__dirname, '../', ...args]); | ||
|
||
const DIRS_TO_WATCH = [ | ||
p('dist'), | ||
p('src') | ||
]; | ||
|
||
const FILTERS = { | ||
JS: [/\.js/gi], | ||
TS: [/\.ts(\.d)?/gi] | ||
} | ||
|
||
const ACTION_MAP = { | ||
JS: [stopServer, startServer] | ||
} | ||
|
||
var serverInstance; | ||
|
||
function onFileChanged(eventType, filename) { | ||
console.log('file %s: %s', eventType, filename); | ||
// add debounce | ||
} | ||
|
||
function startServer() { | ||
serverInstance = exec('npm run start', (err, stdout, stderr) => { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
console.log(stdout); | ||
}); | ||
} | ||
|
||
function stopServer() { | ||
serverInstance.kill('SIGHUP'); | ||
} | ||
|
||
DIRS_TO_WATCH.forEach((dir) => { | ||
fs.watch(dir, {encoding: 'buffer'}, onFileChanged) | ||
}); | ||
startServer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello world'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
}, | ||
"compileOnSave": false, | ||
"files": [ | ||
"./src/index.ts", | ||
"./src/server.ts", | ||
"./typings/main.d.ts" | ||
] | ||
} |