-
Notifications
You must be signed in to change notification settings - Fork 42
/
watch.js
74 lines (65 loc) · 1.75 KB
/
watch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const chokidar = require("chokidar"),
fs = require("fs-extra"),
path = require("path"),
deepmerge = require("deepmerge");
var pkg = require("./package.json"),
pkgModule = require("./Server/Blog/dnn.json");
if (fs.existsSync("./local.json")) {
var local = require("./local.json");
pkg = deepmerge(pkg, local);
}
var log = console.log.bind(console);
function copy(start, srcRelativePath, destDir) {
if (!fs.existsSync(srcRelativePath)) {
return null;
}
var relPath = path.relative(start, srcRelativePath);
const fullDestPath = path.join(destDir, relPath);
log("Copying: " + srcRelativePath);
return fs
.ensureDir(path.dirname(fullDestPath))
.then(() => fs.copy(srcRelativePath, fullDestPath));
}
var ignore = [
/obj/,
/bin/,
"**/*.{vb,cs,suo,user}",
"**/dnn.json",
"**/*.??proj",
"**/web*.config",
"**/packages.config",
"**/.*"
];
const allDlls = pkgModule.pathsAndFiles.assemblies.map(dll => "bin/" + dll);
const watcher = (src, dest) =>
chokidar
.watch(src, {
ignored: ignore,
persistent: true
})
.on("add", path => copy(src, path, dest))
.on("change", path => copy(src, path, dest));
const ModuleWatcher = watcher(
"Server/Blog",
pkg.dnn.pathsAndFiles.devSitePath + "\\DesktopModules\\Blog"
);
const DllWatcher = chokidar
.watch(allDlls, {
persistent: true
})
.on("add", path => {
copy("bin", path, pkg.dnn.pathsAndFiles.devSitePath + "\\bin");
copy(
"bin",
path.replace(".dll", ".pdb"),
pkg.dnn.pathsAndFiles.devSitePath + "\\bin"
);
})
.on("change", path => {
copy("bin", path, pkg.dnn.pathsAndFiles.devSitePath + "\\bin");
copy(
"bin",
path.replace(".dll", ".pdb"),
pkg.dnn.pathsAndFiles.devSitePath + "\\bin"
);
});