libreoffice-convert 1.3.0 → 1.3.4
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/LICENSE +21 -0
- package/index.js +7 -7
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 René Rössler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const convertWithOptions = (document, format, filter, options, callback) => {
|
|
|
17
17
|
switch (process.platform) {
|
|
18
18
|
case 'darwin': paths = ['/Applications/LibreOffice.app/Contents/MacOS/soffice'];
|
|
19
19
|
break;
|
|
20
|
-
case 'linux': paths = ['/usr/bin/libreoffice', '/usr/bin/soffice'];
|
|
20
|
+
case 'linux': paths = ['/usr/bin/libreoffice', '/usr/bin/soffice', '/snap/bin/libreoffice'];
|
|
21
21
|
break;
|
|
22
22
|
case 'win32': paths = [
|
|
23
23
|
path.join(process.env['PROGRAMFILES(X86)'], 'LIBREO~1/program/soffice.exe'),
|
|
@@ -37,25 +37,25 @@ const convertWithOptions = (document, format, filter, options, callback) => {
|
|
|
37
37
|
return callback(new Error('Could not find soffice binary'));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return callback(null,
|
|
40
|
+
return callback(null, res[0]);
|
|
41
41
|
}
|
|
42
42
|
);
|
|
43
43
|
},
|
|
44
44
|
saveSource: callback => fs.writeFile(path.join(tempDir.name, 'source'), document, callback),
|
|
45
45
|
convert: ['soffice', 'saveSource', (results, callback) => {
|
|
46
|
-
let command =
|
|
46
|
+
let command = `-env:UserInstallation=file://${installDir.name} --headless --convert-to ${format}`;
|
|
47
47
|
if (filter !== undefined) {
|
|
48
48
|
command += `:"${filter}"`;
|
|
49
49
|
}
|
|
50
50
|
command += ` --outdir ${tempDir.name} ${path.join(tempDir.name, 'source')}`;
|
|
51
|
-
|
|
52
|
-
return execFile(
|
|
51
|
+
const args = command.split(' ');
|
|
52
|
+
return execFile(results.soffice, args, callback);
|
|
53
53
|
}],
|
|
54
54
|
loadDestination: ['convert', (results, callback) =>
|
|
55
55
|
async.retry({
|
|
56
56
|
times: asyncOptions.times || 3,
|
|
57
57
|
interval: asyncOptions.interval || 200
|
|
58
|
-
}, (callback) => fs.readFile(path.join(tempDir.name, `source.${format}`), callback), callback)
|
|
58
|
+
}, (callback) => fs.readFile(path.join(tempDir.name, `source.${format.split(":")[0]}`), callback), callback)
|
|
59
59
|
]
|
|
60
60
|
}, (err, res) => {
|
|
61
61
|
tempDir.removeCallback();
|
|
@@ -76,4 +76,4 @@ const convert = (document, format, filter, callback) => {
|
|
|
76
76
|
module.exports = {
|
|
77
77
|
convert,
|
|
78
78
|
convertWithOptions
|
|
79
|
-
};
|
|
79
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libreoffice-convert",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "A simple and fast node.js module for converting office documents to different formats",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/elwerene/libreoffice-convert",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"contributors": [
|
|
19
19
|
"René Rössler <rene@freshx.de>",
|
|
20
20
|
"Dmitrii Kosinov <dnk@kakveselo.ru>",
|
|
21
|
-
"Brian Chong <bgorhoball@protonmail.com>"
|
|
21
|
+
"Brian Chong <bgorhoball@protonmail.com>",
|
|
22
|
+
"Võ Văn Khoa"
|
|
22
23
|
],
|
|
23
24
|
"license": "MIT",
|
|
24
25
|
"dependencies": {
|