Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const exec = (cmd, args, opts) => {
// Use `Observable` support if merged https://github.com/sindresorhus/execa/pull/26
const cp = execa(cmd, args, opts);
return Observable.merge(
streamToObservable(cp.stdout.pipe(split()), {await: cp}),
streamToObservable(cp.stderr.pipe(split()), {await: cp})
).filter(Boolean);
};
stream(query: Query): Observable> {
return new Observable((subscriber: Observer>): void => {
if (!this.open) {
subscriber.error(new Error('Cannot run query; connection is not open.'));
return;
}
if (query.getClauses().length === 0) {
subscriber.error(Error('Cannot run query: no clauses attached to the query.'));
return;
}
const session = this.session();
if (!session) {
throw Error('Cannot run query: connection is not open.');
}
// Run the query
stream(): RxObservable> {
if (!this.connection) {
return new Observable((subscriber: Observer>): void => {
subscriber.error(new Error('Cannot run query; no connection object available.'));
});
}
return this.connection.stream(this);
}