From 0179aa10f02bc610ab898da0a0efdc6da99432de Mon Sep 17 00:00:00 2001 From: "Jocelyn Badgley (Twipped)" Date: Thu, 27 Feb 2020 20:41:51 -0800 Subject: [PATCH] Fix File.toJson() not serializing correctly --- gulp/content/file.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/gulp/content/file.js b/gulp/content/file.js index e305da5..c5f4621 100644 --- a/gulp/content/file.js +++ b/gulp/content/file.js @@ -29,10 +29,7 @@ module.exports = exports = class File { } // remove the public root and any _images segment from the dir - const dir = file.dir.split('/'); - if (dir[0] === 'public') dir.shift(); - const i = dir.indexOf('_images'); - if (i > -1) dir.splice(i, 1); + const dir = this._dir(file.dir); this.kind = kind(filepath); this.type = type(filepath); @@ -51,6 +48,7 @@ module.exports = exports = class File { this.serializable = [ 'kind', 'type', + 'cwd', 'ext', 'input', 'base', @@ -63,6 +61,14 @@ module.exports = exports = class File { ]; } + _dir (dir) { + dir = dir.split('/'); + if (dir[0] === 'public') dir.shift(); + const i = dir.indexOf('_images'); + if (i > -1) dir.splice(i, 1); + return dir; + } + load () {} tasks () { @@ -75,18 +81,7 @@ module.exports = exports = class File { } toJson () { - return pick(this.serializable, [ - 'preprocessed', - 'type', - 'kind', - 'input', - 'base', - 'dir', - 'name', - 'basename', - 'ext', - 'dimensions', - ]); + return pick(this, this.serializable); } };