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 {
|
try {
|
||||||
const data = JSON.parse(fs.readFileSync(filePath));
|
const data = JSON.parse(fs.readFileSync(filePath));
|
||||||
return data[ident] || {};
|
return JSON.stringify(data[ident] || {});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
fs.writeFileSync(filePath, JSON.stringify({}));
|
fs.writeFileSync(filePath, JSON.stringify({}));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const md5File = require('md5-file');
|
const md5File = require('md5-file');
|
||||||
const deepEqual = require('fast-deep-equal');
|
|
||||||
const shellExec = require('shell-exec');
|
const shellExec = require('shell-exec');
|
||||||
const data = require('./data');
|
const data = require('./data');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
@@ -50,7 +49,7 @@ module.exports = async function pkgcomp(config, ident, opts = defaultOptions) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// check if the command should be run
|
// 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) {
|
if (runCmd) {
|
||||||
const res = await execCommand(config.cmd);
|
const res = await execCommand(config.cmd);
|
||||||
|
|||||||
Reference in New Issue
Block a user