Skip to content

Commit

Permalink
feat: 🎸 attempts to fix travis bug
Browse files Browse the repository at this point in the history
  • Loading branch information
touv committed Jul 16, 2020
1 parent 9d87a1c commit 6f31157
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/analytics/src/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ export default async function expand(data, feed) {
const output = ezs.createPipeline(this.input, statements)
.pipe(ezs.catch())
.on('data', async ({ id, value }) => {
const obj = await this.store.get(id);
if (obj) {
try {
const obj = await this.store.get(id);
set(obj, path, value);
feed.write(obj);
} catch (e) {
feed.stop(e);
}
})
.on('error', (e) => feed.stop(e));
whenFinish = new Promise((resolve) => output.on('end', resolve));
}
if (this.isLast()) {
return whenFinish
.then(async () => {
.then(() => {
this.store.close();
return feed.close();
})
Expand Down
28 changes: 28 additions & 0 deletions packages/analytics/test/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,32 @@ describe('no expand', () => {
done();
});
});
test('with a script that loses the identifier', (done) => {
const input = [
{ a: 1, b: 'a' },
{ a: 2, b: 'b' },
{ a: 3, b: 'c' },
{ a: 4, b: 'd' },
{ a: 5, b: 'e' },
{ a: 6, b: 'f' },
];
const script = `
[use]
plugin = analytics
[replace]
path = value
value = get('value').toUpper()
`;

from(input)
.pipe(ezs('expand', { path: 'b', script }))
.pipe(ezs.catch())
.on('error', () => {
done();
})
.on('end', () => {
done(new Error('Error is the right behavior'));
});
});
});

0 comments on commit 6f31157

Please sign in to comment.