Skip to content

Commit

Permalink
Defer sharp import
Browse files Browse the repository at this point in the history
  • Loading branch information
typpo committed May 28, 2020
1 parent aeae79f commit cca1d14
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/graphviz.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const sharp = require('sharp');
const Viz = require('viz.js');
const { Module, render } = require('viz.js/full.render.js');

Expand All @@ -12,6 +11,8 @@ async function renderGraphviz(graphStr, opts) {
engine,
});
if (format === 'png') {
// Defer require of sharp as it is not supported by docker container.
const sharp = require('sharp');
const img = sharp(Buffer.from(result));
if (width && height) {
img.resize({
Expand Down

0 comments on commit cca1d14

Please sign in to comment.