Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,13 @@ 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.4 (Nov 9, 2014)

* Support for pidfile argument

### 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
55 changes: 37 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,50 @@ 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.stdout) {
args.push('--stdout');
}
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);
}
if (options.pidfile) {
args.push('--pidfile');
args.push(options.pidfile);
}
}

args.push(file);

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);
Expand All @@ -63,8 +82,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()));
}

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "unoconv",
"version": "0.1.2",
"version": "0.1.5",
"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"
},
"main": "./index",
"repository": {
"type": "git",
"url": "https://github.com/gfloyd/node-unoconv.git"
"url": "https://github.com/colearnr/node-unoconv.git"
},
"keywords": [
"unoconv",
Expand Down