-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docz-core): add doczrc config watcher on dev
- Loading branch information
1 parent
18e6c55
commit 5aa0455
Showing
7 changed files
with
43 additions
and
5 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
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 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 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 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
19 changes: 19 additions & 0 deletions
19
core/docz-core/src/machines/devServer/services/watchConfig.ts
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,19 @@ | ||
import * as path from 'path' | ||
import sh from 'shelljs' | ||
|
||
import { ServerMachineCtx as Context } from '../context' | ||
import { configWatcher } from '../../../states/config' | ||
import * as paths from '../../../config/paths' | ||
|
||
export const watchConfig = (ctx: Context) => () => { | ||
const watcher = configWatcher(ctx.args) | ||
const copyDoczrc = () => sh.cp(ctx.doczrcFilepath, paths.docz) | ||
const deleteDoczrc = () => sh.rm(path.join(paths.docz, 'doczrc.js')) | ||
|
||
watcher | ||
.on('add', copyDoczrc) | ||
.on('change', copyDoczrc) | ||
.on('unlink', deleteDoczrc) | ||
|
||
return () => watcher.close() | ||
} |
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