From 514584e03aa3a65fc0330bb88a3541e904e61d4c Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Sat, 8 Nov 2014 23:31:48 +0000 Subject: [PATCH 1/4] Support for more unoconv options. Tested with the latest unoconv git 0.6.0 --- README.md | 6 ++++++ index.js | 37 +++++++++++++++++++++++++++++-------- package.json | 6 +++--- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9063ad9..7a49981 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,9 @@ This function parses the output of `unoconv --show` to attempt to detect support `callback` gets the arguments `err` and `result`. `result` is an object containing a collection of supported document types and output formats. +## API + +### 0.1.3 (Nov 7, 2014) + +* Support for more unoconv options +* Bug fix: Error will be based on return code from spawn instead of data in stderr diff --git a/index.js b/index.js index 430bf47..bbde64a 100644 --- a/index.js +++ b/index.js @@ -29,20 +29,41 @@ unoconv.convert = function(file, outputFormat, options, callback) { } args = [ - '-f' + outputFormat, - '--stdout' + '-f' + outputFormat ]; - if (options && options.port) { - args.push('-p' + options.port) + if (options) { + if (options.port) { + args.push('-p' + options.port) + } + if (options.verbose) { + args.push('-v'); + } + if (options.output) { + args.push('--output'); + args.push(options.output); + } + if (options.doctype) { + args.push('-d' + options.doctype); + } + if (options.exportStr) { + args.push('-e' + options.exportStr); + } + if (options.nolaunch) { + args.push('-n'); + } + if (options.template) { + args.push('-t' + options.template); + } + if (options.timeout) { + args.push('-T' + options.timeout); + } } - args.push(file); if (options && options.bin) { bin = options.bin; } - child = childProcess.spawn(bin, args, function (err, stdout, stderr) { if (err) { return callback(err); @@ -63,8 +84,8 @@ unoconv.convert = function(file, outputFormat, options, callback) { stderr.push(data); }); - child.on('exit', function () { - if (stderr.length) { + child.on('exit', function (code, signal) { + if (code !== 0 && stderr.length) { return callback(new Error(Buffer.concat(stderr).toString())); } diff --git a/package.json b/package.json index fb76b19..e438693 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "unoconv", - "version": "0.1.2", + "version": "0.1.3", "description": "Wrapper for converting documents with unoconv.", - "homepage": "https://github.com/gfloyd/node-unoconv", + "homepage": "https://github.com/colearnr/node-unoconv", "author": { "name": "Graham Floyd", "email": "grahamf@gmail.com" @@ -10,7 +10,7 @@ "main": "./index", "repository": { "type": "git", - "url": "https://github.com/gfloyd/node-unoconv.git" + "url": "https://github.com/colearnr/node-unoconv.git" }, "keywords": [ "unoconv", From dc5be9e9a7c352cd3ed1d9a73e0fa8963d6848ce Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Sun, 9 Nov 2014 21:07:15 +0000 Subject: [PATCH 2/4] Support for pidfile argument --- README.md | 4 ++++ index.js | 7 +++++++ package.json | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a49981..781843e 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,10 @@ This function parses the output of `unoconv --show` to attempt to detect support ## API +### 0.1.4 (Nov 9, 2014) + +* Support for pidfile argument + ### 0.1.3 (Nov 7, 2014) * Support for more unoconv options diff --git a/index.js b/index.js index bbde64a..ab32b89 100644 --- a/index.js +++ b/index.js @@ -43,6 +43,9 @@ unoconv.convert = function(file, outputFormat, options, callback) { args.push('--output'); args.push(options.output); } + if (options.stdout) { + args.push('--stdout'); + } if (options.doctype) { args.push('-d' + options.doctype); } @@ -58,6 +61,10 @@ unoconv.convert = function(file, outputFormat, options, callback) { if (options.timeout) { args.push('-T' + options.timeout); } + if (options.pidfile) { + args.push('--pidfile'); + args.push(options.pidfile); + } } args.push(file); diff --git a/package.json b/package.json index e438693..f691133 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unoconv", - "version": "0.1.3", + "version": "0.1.4", "description": "Wrapper for converting documents with unoconv.", "homepage": "https://github.com/colearnr/node-unoconv", "author": { From 0331b5bd7d42c71de967c47aa3fa860e56dd01ec Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Thu, 7 Jan 2016 15:16:16 +0000 Subject: [PATCH 3/4] Fix for modern nodejs versions --- index.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/index.js b/index.js index ab32b89..49b9355 100644 --- a/index.js +++ b/index.js @@ -71,17 +71,8 @@ unoconv.convert = function(file, outputFormat, options, callback) { if (options && options.bin) { bin = options.bin; } - child = childProcess.spawn(bin, args, function (err, stdout, stderr) { - if (err) { - return callback(err); - } - if (stderr) { - return callback(new Error(stderr.toString())); - } - - callback(null, stdout); - }); + child = childProcess.spawn(bin, args); child.stdout.on('data', function (data) { stdout.push(data); From 4d5f61ee4636bd391404cec4671b8c34b7721b95 Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Thu, 7 Jan 2016 15:18:00 +0000 Subject: [PATCH 4/4] Bump up version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f691133..0dbc999 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unoconv", - "version": "0.1.4", + "version": "0.1.5", "description": "Wrapper for converting documents with unoconv.", "homepage": "https://github.com/colearnr/node-unoconv", "author": {