libreoffice-convert 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +6 -1
- package/package.json +1 -1
- package/tests/convert.test.js +10 -0
package/index.js
CHANGED
|
@@ -61,7 +61,12 @@ const convertWithOptions = (document, format, filter, options, callback) => {
|
|
|
61
61
|
args.push(tempDir.name);
|
|
62
62
|
args.push(path.join(tempDir.name, fileName));
|
|
63
63
|
|
|
64
|
-
return execFile(results.soffice, args, execOptions,
|
|
64
|
+
return execFile(results.soffice, args, execOptions, (err, stdout, stderr) => {
|
|
65
|
+
// warnings might also be emitted to stderr
|
|
66
|
+
if (stderr && stderr.toLowerCase().includes('error'))
|
|
67
|
+
callback(new Error('Error calling soffice: ' + stderr));
|
|
68
|
+
else callback(err, stdout, stderr);
|
|
69
|
+
});
|
|
65
70
|
}],
|
|
66
71
|
loadDestination: ['convert', (results, callback) =>
|
|
67
72
|
async.retry({
|
package/package.json
CHANGED
package/tests/convert.test.js
CHANGED
|
@@ -31,4 +31,14 @@ describe('convert', () => {
|
|
|
31
31
|
convert(docx, 'txt', undefined, expectHello(done));
|
|
32
32
|
}, 100);
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
it('should fail when libreoffice encounters an error', (done) => {
|
|
36
|
+
// call with invalid document: a buffer starting with PNG header but data is missing
|
|
37
|
+
const badPng = Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]);
|
|
38
|
+
convert(badPng, 'txt', undefined, (err, result) => {
|
|
39
|
+
expect(err).toBeInstanceOf(Error);
|
|
40
|
+
expect(err.message).toMatch(/Error calling soffice:/);
|
|
41
|
+
done();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
34
44
|
});
|