Skip to content

Commit d9c15df

Browse files
authored
fix(CLI): Re-add the wordwrap dependency (#8)
1 parent c23b2ee commit d9c15df

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

cli.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ async function main () {
1010
return
1111
}
1212
const result = await lookup(query)
13+
1314
if (result) {
14-
console.log(wrap(result.text))
15+
console.log(`\x1b[33m%s\x1b[0m`, wrap(`${result.title}: ${result.description}`))
16+
console.log(wrap(result.extract))
1517
} else {
1618
console.log('no results :[')
1719
}

package-lock.json

+13-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
]
2828
},
2929
"dependencies": {
30-
"node-fetch": "^2.6.1"
30+
"node-fetch": "^2.6.1",
31+
"wordwrap": "^1.0.0"
3132
}
3233
}

test.js

+22
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,25 @@ test('alternate languages', async () => {
1919
const result = await lookup('Muñeca', 'es')
2020
expect(result.extract).toMatch('Una muñeca es una figura')
2121
})
22+
23+
24+
// cli tests
25+
const { spawn } = require('child_process')
26+
27+
test('cli', async (done) => {
28+
const reverse = spawn('node', ['cli.js', 'pomology'])
29+
const chunks = []
30+
31+
reverse.stdout.on('data', (chunk) => {
32+
chunks.push(chunk)
33+
});
34+
35+
reverse.stdout.on('end', () => {
36+
const output = Buffer
37+
.concat(chunks)
38+
.toString()
39+
40+
expect(output).toContain('Pomology:')
41+
done()
42+
});
43+
});

0 commit comments

Comments
 (0)