From b93defbf4d1806356cd49768401cd3d5445a9a50 Mon Sep 17 00:00:00 2001 From: joe fleming Date: Fri, 5 Apr 2019 15:49:16 -0700 Subject: [PATCH] fix: compare stringified objects fixes issue with packages that have no dependencies or devDependencies --- src/data.js | 2 +- src/index.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/data.js b/src/data.js index 3821c6a..8816b6b 100644 --- a/src/data.js +++ b/src/data.js @@ -18,7 +18,7 @@ exports.read = (fileRoot, ident) => { try { const data = JSON.parse(fs.readFileSync(filePath)); - return data[ident] || {}; + return JSON.stringify(data[ident] || {}); } catch (err) { if (err.code === 'ENOENT') { fs.writeFileSync(filePath, JSON.stringify({})); diff --git a/src/index.js b/src/index.js index b04d375..23cfc85 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,5 @@ const path = require('path'); const md5File = require('md5-file'); -const deepEqual = require('fast-deep-equal'); const shellExec = require('shell-exec'); const data = require('./data'); const utils = require('./utils'); @@ -50,7 +49,7 @@ module.exports = async function pkgcomp(config, ident, opts = defaultOptions) { }; // check if the command should be run - const runCmd = Boolean(opts.force || (doExec && !deepEqual(packageHistory, payload))); + const runCmd = Boolean(opts.force || (doExec && packageHistory !== JSON.stringify(payload))); if (runCmd) { const res = await execCommand(config.cmd);