libreoffice-convert
Advanced tools
Comparing version 1.4.1 to 1.5.0
32
index.js
@@ -13,2 +13,3 @@ 'use strict'; | ||
const asyncOptions = (options || {}).asyncOptions || {}; | ||
const execOptions = (options || {}).execOptions || {}; | ||
const tempDir = tmp.dirSync({prefix: 'libreofficeConvert_', unsafeCleanup: true, ...tmpOptions}); | ||
@@ -49,9 +50,14 @@ const installDir = tmp.dirSync({prefix: 'soffice', unsafeCleanup: true, ...tmpOptions}); | ||
convert: ['soffice', 'saveSource', (results, callback) => { | ||
let command = `-env:UserInstallation=${url.pathToFileURL(installDir.name)} --headless --convert-to ${format}`; | ||
if (filter !== undefined) { | ||
command += `:"${filter}"`; | ||
} | ||
command += ` --outdir ${tempDir.name} ${path.join(tempDir.name, 'source')}`; | ||
const args = command.split(' '); | ||
return execFile(results.soffice, args, callback); | ||
let filterParam = filter?.length ? `:${filter}` : ""; | ||
let fmt = !(filter ?? "").includes(" ") ? `${format}${filterParam}` : `"${format}${filterParam}"`; | ||
let args = []; | ||
args.push(`-env:UserInstallation=${url.pathToFileURL(installDir.name)}`); | ||
args.push('--headless'); | ||
args.push('--convert-to'); | ||
args.push(fmt); | ||
args.push('--outdir'); | ||
args.push(tempDir.name); | ||
args.push(path.join(tempDir.name, 'source')); | ||
return execFile(results.soffice, args, execOptions, callback); | ||
}], | ||
@@ -64,11 +70,9 @@ loadDestination: ['convert', (results, callback) => | ||
] | ||
}, (err, res) => { | ||
}).then( (res) => { | ||
return callback(null, res.loadDestination); | ||
}).catch( (err) => { | ||
return callback(err); | ||
}).finally( () => { | ||
tempDir.removeCallback(); | ||
installDir.removeCallback(); | ||
if (err) { | ||
return callback(err); | ||
} | ||
return callback(null, res.loadDestination); | ||
}); | ||
@@ -75,0 +79,0 @@ }; |
{ | ||
"name": "libreoffice-convert", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "A simple and fast node.js module for converting office documents to different formats", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19829
128