fix: compare stringified objects
fixes issue with packages that have no dependencies or devDependencies
This commit is contained in:
@@ -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({}));
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user