presets: only watch file in non-test environment

This commit is contained in:
Micooz 2017-10-13 16:23:28 +08:00
parent ec85efe107
commit 92c20bf61c
No known key found for this signature in database
GPG Key ID: 002FB5DD584D6CB1

@ -300,11 +300,13 @@ export default class AccessControlPreset extends IPreset {
const aclPath = path.resolve(process.cwd(), acl);
// note: should load rules once server up
reloadRules(aclPath);
fs.watchFile(aclPath, (curr, prev) => {
if (curr.mtime > prev.mtime) {
reloadRules(aclPath);
}
});
if (process.env.NODE_ENV !== 'test') {
fs.watchFile(aclPath, (curr, prev) => {
if (curr.mtime > prev.mtime) {
reloadRules(aclPath);
}
});
}
}
constructor({acl, max_tries = DEFAULT_MAX_TRIES}) {