UNPKG

@coat/cli

Version:

TODO: See #3

28 lines (27 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.removeUnmanagedTasksFromLockfile = removeUnmanagedTasksFromLockfile; var _immer = _interopRequireDefault(require("immer")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Removes unmanaged tasks from a coat lockfile. * * If a task is no longer specified by one of the extended templates of this * project, the task result should be removed to clean up the lockfile. * * @param lockfile A local or global coat lockfile * @param tasks Tasks that are part of the current coat project */ function removeUnmanagedTasksFromLockfile(lockfile, tasks) { const taskIds = new Set(tasks.map(task => task.id)); return (0, _immer.default)(lockfile, draft => { draft.setup = Object.entries(draft.setup).reduce((accumulator, [taskId, taskResult]) => { if (taskIds.has(taskId)) { accumulator[taskId] = taskResult; } return accumulator; }, {}); }); }