From 34a40e1674e871ae3bbf62693a28e660f7de46a4 Mon Sep 17 00:00:00 2001 From: argv-minus-one Date: Tue, 30 Apr 2019 19:57:44 -0700 Subject: [PATCH 1/2] Skip reading background dimensions if they aren't needed. The dimensions of the background image are used as a default window size if the specification does not contain a `window.size` object. Skipping this is useful because reading the background image's dimensions won't work if it's in a format that `image-size` doesn't understand, particularly PDF. --- lib/appdmg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/appdmg.js b/lib/appdmg.js index 2c4cc60..bf141f2 100644 --- a/lib/appdmg.js +++ b/lib/appdmg.js @@ -279,7 +279,7 @@ module.exports = exports = function (options) { **/ pipeline.addStep('Reading background dimensions', function (next) { - if (!global.opts.background) return next.skip() + if (!global.opts.background || (global.opts.window && global.opts.window.size)) return next.skip() sizeOf(resolvePath(global.opts.background), function (err, value) { if (err) return next(err) From 1f501a119fcd8bbd73eaa89d0a3529b7ff519e4a Mon Sep 17 00:00:00 2001 From: argv-minus-one Date: Tue, 30 Apr 2019 22:15:37 -0700 Subject: [PATCH 2/2] =?UTF-8?q?Better=20error=20message=20for=20=E2=80=9Cr?= =?UTF-8?q?eading=20background=20dimensions=E2=80=9D=20step.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When reading the background image's dimensions fails, appdmg now tells the user that the error can be avoided by giving `window.size` in the JSON specification. --- lib/appdmg.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/appdmg.js b/lib/appdmg.js index bf141f2..3ee0bd2 100644 --- a/lib/appdmg.js +++ b/lib/appdmg.js @@ -282,7 +282,11 @@ module.exports = exports = function (options) { if (!global.opts.background || (global.opts.window && global.opts.window.size)) return next.skip() sizeOf(resolvePath(global.opts.background), function (err, value) { - if (err) return next(err) + if (err) { + const err2 = new Error(`Could not read dimensions of background image: ${err.name}: ${err.message}\nTo avoid this, give an explicit window size (window.size property) in your dmg specification file.`) + err2.stack = `${err2.stack}\nCaused by: ${err.stack}` + return next(err2) + } global.bkgsize = [value.width, value.height] next(null)