Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return nsfw(filename, async (events: nsfw.ChangeEvent[]) => {
try {
for (const event of events) {
switch (event.action) {
case nsfw.actions.CREATED:
case nsfw.actions.MODIFIED:
await this.slurpLogConfigFile(filename);
this.logConfigChangedEvent.fire(undefined);
break;
}
}
} catch (e) {
console.error(`Error reading log config file ${filename}: ${e}`);
}
}).then((watcher: nsfw.NSFW) => {
watcher.start();
import {Emitter} from 'event-kit';
import nsfw from 'nsfw';
import {watchPath} from 'atom';
import path from 'path';
import EventLogger from './event-logger';
const actionText = new Map([
[nsfw.actions.CREATED, 'created'],
[nsfw.actions.DELETED, 'deleted'],
[nsfw.actions.MODIFIED, 'modified'],
[nsfw.actions.RENAMED, 'renamed'],
]);
export default class FileSystemChangeObserver {
constructor(repository) {
this.hasAtomAPI = watchPath !== undefined;
this.emitter = new Emitter();
this.repository = repository;
this.logger = new EventLogger('fs watcher');
this.started = false;
}
async start() {
await this.watchRepository();
import {Emitter} from 'event-kit';
import nsfw from 'nsfw';
import {watchPath} from 'atom';
import path from 'path';
import EventLogger from './event-logger';
const actionText = new Map([
[nsfw.actions.CREATED, 'created'],
[nsfw.actions.DELETED, 'deleted'],
[nsfw.actions.MODIFIED, 'modified'],
[nsfw.actions.RENAMED, 'renamed'],
]);
export default class FileSystemChangeObserver {
constructor(repository) {
this.hasAtomAPI = watchPath !== undefined;
this.emitter = new Emitter();
this.repository = repository;
this.logger = new EventLogger('fs watcher');
this.started = false;
}
let watcher: nsfw.NSFW | undefined = await nsfw(fs.realpathSync(basePath), (events: nsfw.ChangeEvent[]) => {
for (const event of events) {
if (event.action === nsfw.actions.CREATED) {
this.pushAdded(watcherId, this.resolvePath(event.directory, event.file!));
}
if (event.action === nsfw.actions.DELETED) {
this.pushDeleted(watcherId, this.resolvePath(event.directory, event.file!));
}
if (event.action === nsfw.actions.MODIFIED) {
this.pushUpdated(watcherId, this.resolvePath(event.directory, event.file!));
}
if (event.action === nsfw.actions.RENAMED) {
this.pushDeleted(watcherId, this.resolvePath(event.directory, event.oldFile!));
this.pushAdded(watcherId, this.resolvePath(event.newDirectory || event.directory, event.newFile!));
}
}
}, {
errorCallback: error => {
let watcher: nsfw.NSFW | undefined = await nsfw(fs.realpathSync(basePath), (events: nsfw.ChangeEvent[]) => {
for (const event of events) {
if (event.action === nsfw.actions.CREATED) {
this.pushAdded(watcherId, this.resolvePath(event.directory, event.file!));
}
if (event.action === nsfw.actions.DELETED) {
this.pushDeleted(watcherId, this.resolvePath(event.directory, event.file!));
}
if (event.action === nsfw.actions.MODIFIED) {
this.pushUpdated(watcherId, this.resolvePath(event.directory, event.file!));
}
if (event.action === nsfw.actions.RENAMED) {
this.pushDeleted(watcherId, this.resolvePath(event.directory, event.oldFile!));
this.pushAdded(watcherId, this.resolvePath(event.newDirectory || event.directory, event.newFile!));
}
}
}, {
errorCallback: error => {