Skip to content
Open
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
11 changes: 10 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,16 @@ app.on('ready', function() {
// https://gist.github.com/twolfson/0d374d9d7f26eefe7d38
var args = [
function handleCapture(img) {
done(null, img.toPng())
if(img.toPng) {
done(null, img.toPng());

} else if(img.toPNG) {
// @see https://github.com/electron/electron/blob/master/docs/api/native-image.md#imagetopngoptions
done(null, img.toPNG());

} else {
done(new Error('no png method found in electrons image.'));
Copy link

@wojtekmaj wojtekmaj Sep 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's what we have package.json for is to be sure this will never happen.

So, we could have it in one line:

const toPng = img.toPng || img.toPNG;
done(null, toPng());

If you really think that's necessary, between line 1 and 2 you could add

if (!toPng) {
    done(new Error('Neither toPng nor toPNG method was found in Electron\'s image.'));
}

}
}
]
if (clip) args.unshift(clip)
Expand Down