Skip to content

Commit

Permalink
[fix] eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrmatos committed Jun 6, 2016
1 parent 3b77698 commit 326a91d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class Electron {
tmpDir
};

let shouldAccessLocalFiles;

// filter undefined options
convertOptions = pick(convertOptions, (val) => {
return val !== undefined;
});
convertOptions = pick(convertOptions, (val) => val !== undefined);

this.reporter = reporter;

Expand All @@ -49,24 +49,31 @@ class Electron {
});

if (reporter.documentStore.model.entityTypes.TemplateType) {
// eslint-disable-next-line no-param-reassign
reporter.documentStore.model.entityTypes.TemplateType.electron = {
type: 'jsreport.ElectronType'
};
}

shouldAccessLocalFiles = definition.options.hasOwnProperty('allowLocalFilesAccess') ?
definition.options.allowLocalFilesAccess : false;

if (!reporter.__electron_html_to__) {
// eslint-disable-next-line no-param-reassign
reporter.__electron_html_to__ = Promises.promisify(electronConvert({
...convertOptions,
allowLocalFilesAccess: definition.options.hasOwnProperty('allowLocalFilesAccess') ? definition.options.allowLocalFilesAccess : false
allowLocalFilesAccess: shouldAccessLocalFiles
}));
}
}

execute(request, response) {
// eslint-disable-next-line no-param-reassign
request.template.electron = request.template.electron || {};

this.reporter.logger.debug('Electron Pdf recipe start.');

// eslint-disable-next-line no-param-reassign
request.template.recipe = 'html';

return recipe(this.reporter.__electron_html_to__, request, response);
Expand All @@ -75,11 +82,15 @@ class Electron {

export default function(reporter, definition) {
if (!Object.keys(definition.options).length) {
// eslint-disable-next-line no-param-reassign
definition.options = reporter.options.electron || {};
}

// eslint-disable-next-line no-param-reassign
definition.options.strategy = definition.options.strategy || 'dedicated-process';
// eslint-disable-next-line no-param-reassign
definition.options.tmpDir = reporter.options.tempDirectory;

// eslint-disable-next-line no-param-reassign
reporter[definition.name] = new Electron(reporter, definition);
}
3 changes: 3 additions & 0 deletions src/recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ export default function(conversion, request, response) {
landscape: parseBoolean(options.landscape, false)
}
}).then((result) => {
/* eslint-disable no-param-reassign */
response.headers['Content-Type'] = 'application/pdf';
response.headers['Content-Disposition'] = 'inline; filename="report.pdf"';
response.headers['File-Extension'] = 'pdf';
response.headers['Number-Of-Pages'] = result.numberOfPages;
/* eslint-enable no-param-reassign */

return toArray(result.stream);
}).then((arr) => {
// eslint-disable-next-line no-param-reassign
response.content = Buffer.concat(arr);
}));
});
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import path from 'path';
import jsreport from 'jsreport-core';

/* eslint-disable prefer-arrow-callback */
describe('electron pdf', function() {
let reporter;

Expand Down

0 comments on commit 326a91d

Please sign in to comment.