Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const watch = async givenPath => {
let ignoreBefore = 0;
let ignoreAll = false;
logger.verbose(getMessage("Watcher_Start_Log", { path: givenPath }));
const rootPath = fs.realpathSync(givenPath);
if (rootPath !== givenPath) {
logger.debug(getMessage("Watcher_Path_Resolved_Log", { path: rootPath }));
}
const fullPath = relativePath => path.join(rootPath, relativePath);
const isUnderRoot = pathToCheck =>
isUnderPath(rootPath, fullPath(pathToCheck));
const shouldIgnoreFile = watchPath => {
const isInterestingPath =
isSamePath(rootPath, watchPath) ||
(isUnderRoot(watchPath) && isPathRelatedToSite(rootPath, watchPath));
return !isInterestingPath;
const withCloneModeNotification = asyncCallback => async (...args) => {
const cloneModeBefore = isCloneMode();
const result = await asyncCallback(...args);
const cloneModeAfter = isCloneMode();
if (cloneModeBefore && !cloneModeAfter) {
logger.verbose(getMessage("Index_Clone_Complete_Log"));
notifyAdmin("clone-complete");
}
return result;
};
return (socket, next) => {
const origin = socket.handshake.headers.origin || "";
const hostname = origin && new URL(origin).hostname;
if (!allowedDomains.includes(hostname)) {
logger.warn(getMessage("AdminToken_Error_Log", { origin }));
return next(new Error(getMessage("Origin_Error")));
}
logger.verbose(getMessage("Origin_Accepted_Log", { origin }));
next();
};
}