Skip to content

Commit

Permalink
ESLint autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Oct 16, 2017
1 parent d20b289 commit 2d78188
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/bin/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ const pathETCD = resolve('/', argz._[0]);
const client = makeEtcdClient(argz);

const watcher = client.watcher(pathETCD, null, {recursive: true});
createWatcher$(watcher).do(action => process.stdout.write(`${stringify(action)}\n`)).toPromise();
createWatcher$(watcher)
.do(action => process.stdout.write(`${stringify(action)}\n`))
.toPromise();
6 changes: 5 additions & 1 deletion src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const createFetch$ = (client, cwd) => {
client.get(cwd, {recursive: true}, (err, data) => cb(err, data))
);

return Observable.of(list).map(f => f()).mergeAll().retry(Infinity).map(parseAction);
return Observable.of(list)
.map(f => f())
.mergeAll()
.retry(Infinity)
.map(parseAction);
};

export default createFetch$;
8 changes: 7 additions & 1 deletion src/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ const set = (store, {action, node, prevNode}) => {
return node;
}

const storeKey = path.join(store.key, path.relative(store.key, node.key).split('/').shift());
const storeKey = path.join(
store.key,
path
.relative(store.key, node.key)
.split('/')
.shift()
);

return set_(
'nodes',
Expand Down
6 changes: 5 additions & 1 deletion src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const createStore = (node$, indexer) => {

const replayed$ = store$.publishReplay(1);

const ready = key => replayed$.first().pluck(key).toPromise();
const ready = key =>
replayed$
.first()
.pluck(key)
.toPromise();

return {
store: ready,
Expand Down
5 changes: 4 additions & 1 deletion src/test/etcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ test('should composite events observable', async t => {
setEvent
];

const eventsP = events$.take(6).toArray().toPromise();
const eventsP = events$
.take(6)
.toArray()
.toPromise();

[setEvent, deleteEvent, resyncEvent, deleteEvent, setEvent].forEach(event =>
watcher.emit(event.action, event)
Expand Down
4 changes: 3 additions & 1 deletion src/test/fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ test('should load fallback', async t => {
});

test("shouldn't throw error if file doesn't exist", async t => {
const events = await createFallback$(join(__dirname, 'fixtures/nope.json')).toArray().toPromise();
const events = await createFallback$(join(__dirname, 'fixtures/nope.json'))
.toArray()
.toPromise();
t.deepEqual(events, []);
});
10 changes: 8 additions & 2 deletions src/test/resync.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ test('should transform resync event', async t => {
}
];

const events = await watcher$.take(1).toArray().toPromise();
const events = await watcher$
.take(1)
.toArray()
.toPromise();
t.deepEqual(events, expected);
});

Expand Down Expand Up @@ -77,6 +80,9 @@ test('should keep order', async t => {
setEvent
];

const events = await watcher$.take(3).toArray().toPromise();
const events = await watcher$
.take(3)
.toArray()
.toPromise();
t.deepEqual(events, expected);
});
4 changes: 3 additions & 1 deletion src/test/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ test('should create file', async t => {
test('should do nothing if file is not defined', async t => {
const save = createSave();

const events = await save(Observable.of(fallback)).toArray().toPromise();
const events = await save(Observable.of(fallback))
.toArray()
.toPromise();
t.deepEqual(events, [fallback]);
});
8 changes: 6 additions & 2 deletions src/util/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const stat$ = Observable.bindNodeCallback(stat);

const _readdir$ = Observable.bindNodeCallback(readdir);
export const readdir$ = pathFS =>
_readdir$(pathFS).flatMap(Observable.from).map(entry => join(pathFS, entry));
_readdir$(pathFS)
.flatMap(Observable.from)
.map(entry => join(pathFS, entry));

export const readFile$ = Observable.bindNodeCallback(readFile);
export const readFileUTF8$ = file => readFile$(file, {encoding: 'UTF8'});
Expand All @@ -17,5 +19,7 @@ export const isFile$ = pathFS => stat$(pathFS).map(_stat => _stat.isFile());
export const isDirectory$ = pathFS => stat$(pathFS).map(_stat => _stat.isDirectory());

export const filter$ = curry((predicate, value) =>
predicate(value).filter(Boolean).map(() => value)
predicate(value)
.filter(Boolean)
.map(() => value)
);
8 changes: 6 additions & 2 deletions src/util/test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ test('should throw error on directory sync if etcd throws unknown error', t => {
});

return t.throws(
syncDirectory$(client, join(__dirname, 'fixtures/fs'), '/test').toArray().toPromise(),
syncDirectory$(client, join(__dirname, 'fixtures/fs'), '/test')
.toArray()
.toPromise(),
'UnknownError'
);
});
Expand Down Expand Up @@ -160,7 +162,9 @@ test('should throw error on file sync if etcd throws unknown error', t => {
});

return t.throws(
syncFile$(client, join(__dirname, 'fixtures/fs/foo'), '/test/foo').toArray().toPromise(),
syncFile$(client, join(__dirname, 'fixtures/fs/foo'), '/test/foo')
.toArray()
.toPromise(),
'UnknownError'
);
});
Expand Down
32 changes: 24 additions & 8 deletions src/util/test/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@ const joinTestFolder = (...argz) => join(__dirname, 'fixtures/fs', ...argz);
const mapJoinTestFolder = map(joinTestFolder);

test('should return true if entry is a file', t =>
isFile$(joinTestFolder('foo')).toPromise().then(isFile => t.deepEqual(isFile, true)));
isFile$(joinTestFolder('foo'))
.toPromise()
.then(isFile => t.deepEqual(isFile, true)));

test('should return false if entry is a directory', t =>
isFile$(joinTestFolder('bar')).toPromise().then(isFile => t.deepEqual(isFile, false)));
isFile$(joinTestFolder('bar'))
.toPromise()
.then(isFile => t.deepEqual(isFile, false)));

test('should return error if entry is neither a file nor a directory', t => {
return Promise.all([
isFile$(joinTestFolder('qux')).toPromise().then(() => t.fail(), () => t.pass()),
isFile$(joinTestFolder('qux/quux')).toPromise().then(() => t.fail(), () => t.pass()),
isDirectory$(joinTestFolder('qux')).toPromise().then(() => t.fail(), () => t.pass()),
isDirectory$(joinTestFolder('qux/quux')).toPromise().then(() => t.fail(), () => t.pass())
isFile$(joinTestFolder('qux'))
.toPromise()
.then(() => t.fail(), () => t.pass()),
isFile$(joinTestFolder('qux/quux'))
.toPromise()
.then(() => t.fail(), () => t.pass()),
isDirectory$(joinTestFolder('qux'))
.toPromise()
.then(() => t.fail(), () => t.pass()),
isDirectory$(joinTestFolder('qux/quux'))
.toPromise()
.then(() => t.fail(), () => t.pass())
]);
});

Expand All @@ -39,8 +51,12 @@ test('should read directory content', t =>

test('should return error if entry is not a directory', t =>
Promise.all([
readdir$(joinTestFolder('foo')).toPromise().then(() => t.fail(), () => t.pass()),
readdir$(joinTestFolder('quz')).toPromise().then(() => t.fail(), () => t.pass())
readdir$(joinTestFolder('foo'))
.toPromise()
.then(() => t.fail(), () => t.pass()),
readdir$(joinTestFolder('quz'))
.toPromise()
.then(() => t.fail(), () => t.pass())
]));

test('should filterFile directory content', t =>
Expand Down

0 comments on commit 2d78188

Please sign in to comment.