UNPKG

@coat/cli

Version:

TODO: See #3

37 lines (36 loc) 994 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.polishFiles = polishFiles; var _fileTypes = require("../file-types"); var _getFileHash = require("../util/get-file-hash"); /** * Polishes all files and converts their content into strings. * * Files are polished depending on their type, * e.g. JSON and YAML files are styled with prettier while * TEXT files end with a consistent trailing new line. * * @param files All files that should be polished * @param context The context of the current coat project */ function polishFiles(files, context) { return files.map(file => { const polishFunction = (0, _fileTypes.getPolishFunction)(file); const content = polishFunction(file.content, file.file, context); if (file.once) { return { ...file, content, once: true }; } return { ...file, once: false, content, hash: (0, _getFileHash.getFileHash)(content) }; }); }