fix: compare stringified objects

fixes issue with packages that have no dependencies or devDependencies
This commit is contained in:
2019-04-05 15:49:16 -07:00
parent 4cd6e2922c
commit b93defbf4d
2 changed files with 2 additions and 3 deletions

View File

@@ -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({}));

View File

@@ -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);