theme: automatically reload theme when the file is modified
This commit is contained in:
parent
6e3644d9af
commit
a6542f874f
3 changed files with 13 additions and 3 deletions
|
|
@ -1,6 +1,8 @@
|
|||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
settings = require('./settings')
|
||||
settings = require('./settings'),
|
||||
chokidar = require('chokidar'),
|
||||
ipc
|
||||
|
||||
class Theme {
|
||||
|
||||
|
|
@ -9,6 +11,7 @@ class Theme {
|
|||
this.themes = []
|
||||
this.files = []
|
||||
this.css = []
|
||||
this.watcher = null
|
||||
|
||||
this.defaultColor = '#151a24'
|
||||
this.backgroundColor = this.defaultColor
|
||||
|
|
@ -31,6 +34,12 @@ class Theme {
|
|||
}
|
||||
}
|
||||
|
||||
this.watcher = chokidar.watch(this.files).on('change', ()=>{
|
||||
if (!ipc) ipc = require('./server').ipc
|
||||
this.load()
|
||||
ipc.send('reloadCss')
|
||||
})
|
||||
|
||||
this.load()
|
||||
|
||||
return this
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue