libreoffice-convert 1.5.1 → 1.6.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.
Files changed (3) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +4 -3
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -14,6 +14,7 @@ declare module "libreoffice-convert" {
14
14
  tmpOptions?: Record<string | number | symbol, unknown>;
15
15
  asyncOptions?: { times?: number; interval?: number };
16
16
  sofficeBinaryPaths?: string[];
17
+ fileName?: string;
17
18
  },
18
19
  callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void
19
20
  ): void;
package/index.js CHANGED
@@ -11,6 +11,7 @@ const convertWithOptions = (document, format, filter, options, callback) => {
11
11
  const tmpOptions = (options || {}).tmpOptions || {};
12
12
  const asyncOptions = (options || {}).asyncOptions || {};
13
13
  const execOptions = (options || {}).execOptions || {};
14
+ const fileName = (options || {}).fileName || 'source';
14
15
  const tempDir = tmp.dirSync({prefix: 'libreofficeConvert_', unsafeCleanup: true, ...tmpOptions});
15
16
  const installDir = tmp.dirSync({prefix: 'soffice', unsafeCleanup: true, ...tmpOptions});
16
17
  return async.auto({
@@ -44,7 +45,7 @@ const convertWithOptions = (document, format, filter, options, callback) => {
44
45
  }
45
46
  );
46
47
  },
47
- saveSource: callback => fs.writeFile(path.join(tempDir.name, 'source'), document, callback),
48
+ saveSource: callback => fs.writeFile(path.join(tempDir.name, fileName), document, callback),
48
49
  convert: ['soffice', 'saveSource', (results, callback) => {
49
50
  let filterParam = filter?.length ? `:${filter}` : "";
50
51
  let fmt = !(filter ?? "").includes(" ") ? `${format}${filterParam}` : `"${format}${filterParam}"`;
@@ -55,7 +56,7 @@ const convertWithOptions = (document, format, filter, options, callback) => {
55
56
  args.push(fmt);
56
57
  args.push('--outdir');
57
58
  args.push(tempDir.name);
58
- args.push(path.join(tempDir.name, 'source'));
59
+ args.push(path.join(tempDir.name, fileName));
59
60
 
60
61
  return execFile(results.soffice, args, execOptions, callback);
61
62
  }],
@@ -63,7 +64,7 @@ const convertWithOptions = (document, format, filter, options, callback) => {
63
64
  async.retry({
64
65
  times: asyncOptions.times || 3,
65
66
  interval: asyncOptions.interval || 200
66
- }, (callback) => fs.readFile(path.join(tempDir.name, `source.${format.split(":")[0]}`), callback), callback)
67
+ }, (callback) => fs.readFile(path.join(tempDir.name, `${fileName}.${format.split(":")[0]}`), callback), callback)
67
68
  ]
68
69
  }).then( (res) => {
69
70
  return callback(null, res.loadDestination);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libreoffice-convert",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "A simple and fast node.js module for converting office documents to different formats",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",