Skip to content

Commit

Permalink
fix(core): use Promise from compodoc
Browse files Browse the repository at this point in the history
fix #4
  • Loading branch information
vogloblinsky committed Oct 31, 2017
1 parent 07c39f3 commit 4d74a14
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
61 changes: 34 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
'use strict';
const gutil = require('gulp-util'),
PluginError = gutil.PluginError,
es = require('event-stream'),
through = require('through2'),
compodocModule = require('@compodoc/compodoc'),
PLUGIN_NAME = 'gulp-compodoc';
PluginError = gutil.PluginError,
es = require('event-stream'),
through = require('through2'),
compodocModule = require('@compodoc/compodoc'),
PLUGIN_NAME = 'gulp-compodoc';

function compodoc(options) {
var files = [];
options = options || {};
options = options || {};

return es.through(function(file) {
files.push(file.path);
}, function() {
var stream = this;
files.push(file.path);
}, function() {
var stream = this;

if (files.length === 0) {
stream.emit('error', new PluginError(PLUGIN_NAME, 'No input files for compodoc.'));
stream.emit('end');
return;
} else if (!options.output) {
stream.emit('error', new PluginError(PLUGIN_NAME, 'You must either specify the \'output\' option.'));
stream.emit('end');
return;
} else {
if (files.length === 0) {
stream.emit('error', new PluginError(PLUGIN_NAME, 'No input files for compodoc.'));
stream.emit('end');
return;
} else if (!options.output) {
stream.emit('error', new PluginError(PLUGIN_NAME, 'You must either specify the \'output\' option.'));
stream.emit('end');
return;
} else {
var app = new compodocModule.Application(options);

app.setFiles(files);
app.generate();

process.on('exit', function() {
try {
app.setFiles(files);
app.generate().then(function() {
stream.emit('end');
return;
}, function(error) {
stream.emit('error', new PluginError(PLUGIN_NAME, error));
stream.emit('end');
return;
});
} catch (e) {
stream.emit('error', e);
stream.emit('end');
});

return;
}
});
return;
}
}
});
}

module.exports = compodoc;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"node": ">=5.10.0"
},
"dependencies": {
"@compodoc/compodoc": "^1.0.2",
"@compodoc/compodoc": "^1.0.3",
"event-stream": "^3.3.4",
"gulp-util": "^3.0.7",
"through2": "^2.0.1"
Expand Down

0 comments on commit 4d74a14

Please sign in to comment.