@coat/cli
Version:
TODO: See #3
40 lines (37 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateGlobalLockfile = updateGlobalLockfile;
exports.updateLocalLockfile = updateLocalLockfile;
var _mergeWith = _interopRequireDefault(require("lodash/mergeWith"));
var _constants = require("../constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function mergeWithArrayReplacement(source, target) {
// Replace arrays rather than merging them
if (Array.isArray(target) && Array.isArray(source)) {
return target;
}
}
/**
* Updates a local lockfile and returns the updated copy
*
* @param currentLockfile The current local lockfile
* @param newLockfile New lockfile properties, will be merged with the current lockfile
*/
function updateLocalLockfile(currentLockfile, newLockfile) {
return (0, _mergeWith.default)({}, currentLockfile, {
version: _constants.COAT_LOCAL_LOCKFILE_VERSION
}, newLockfile, mergeWithArrayReplacement);
}
/**
* Updates a global lockfile and returns the updated copy
*
* @param currentLockfile The current global lockfile
* @param newLockfile New lockfile properties, will be merged with the current lockfile
*/
function updateGlobalLockfile(currentLockfile, newLockfile) {
return (0, _mergeWith.default)({}, currentLockfile, {
version: _constants.COAT_GLOBAL_LOCKFILE_VERSION
}, newLockfile, mergeWithArrayReplacement);
}