87 lines
2.1 KiB
JavaScript
87 lines
2.1 KiB
JavaScript
const chokidar = require("chokidar"),
|
|
fs = require("fs-extra"),
|
|
path = require("path"),
|
|
deepmerge = require("deepmerge");
|
|
|
|
var pkg = require("./package.json"),
|
|
pkgInMemoriam = require("./Server/InMemoriam/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))
|
|
.catch((err) => {
|
|
console.error(err);
|
|
});
|
|
}
|
|
|
|
var ignore = [
|
|
/obj/,
|
|
/bin/,
|
|
"**/*.{vb,cs,suo,user}",
|
|
"**/dnn.json",
|
|
"**/*.??proj",
|
|
"**/web*.config",
|
|
"**/packages.config",
|
|
"**/.*"
|
|
];
|
|
|
|
const allDlls = pkgInMemoriam.pathsAndFiles.assemblies
|
|
// .concat(pkgInText.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));
|
|
// Todo: delete events?
|
|
|
|
// Initialize watchers.
|
|
const InMemoriamSkinWatcher = watcher(
|
|
"Themes/Skins/InMemoriamSkin",
|
|
pkg.dnn.pathsAndFiles.devSitePath +
|
|
"\\Portals\\_default\\Skins\\Bring2mind.InMemoriam"
|
|
);
|
|
const InMemoriamWatcher = watcher(
|
|
"Server/InMemoriam",
|
|
pkg.dnn.pathsAndFiles.devSitePath +
|
|
"\\DesktopModules\\MVC\\Bring2mind\\InMemoriam"
|
|
);
|
|
|
|
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"
|
|
);
|
|
});
|