UNPKG

@coat/cli

Version:

TODO: See #3

45 lines (43 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateLockfileFiles = generateLockfileFiles; var _constants = require("../constants"); /** * Generates an array of file objects that are used in coat's lockfiles. * * The lockfile files entries will contain the relative paths and the * once property for files that are only generated once, in order to * track them across sync runs and not touch or delete them later. * * @param files The file entries that will be added to the lockfile */ function generateLockfileFiles(files) { const lockfileFiles = files // The root package.json file next to the coat manifest file // should not be included in the lockfile .filter(file => file.relativePath !== _constants.PACKAGE_JSON_FILENAME).map(file => { if (file.once) { // Once files should not store // the hash of the generated file return { // File paths should be relative from the coat project path: file.relativePath, once: file.once }; } // Continuously managed files should have a hash property // to verify that the content on the disk has not been changed // before overwriting the file return { // File paths should be relative from the coat project path: file.relativePath, once: file.once, hash: file.hash }; }); // Sort lockfile files alphabetically lockfileFiles.sort((a, b) => a.path.localeCompare(b.path)); return lockfileFiles; }