MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / ensureHeader

Function ensureHeader

packages/cli/generators/copyright/header.js:147–164  ·  view source on GitHub ↗

* Ensure the file is updated with the correct header * @param {string} file - JS/TS file * @param {object} pkg - Package json object * @param {object} options - Options

(file, pkg, options = {})

Source from the content-addressed store, hash-verified

145 * @param {object} options - Options
146 */
147async function ensureHeader(file, pkg, options = {}) {
148 const fs = options.fs || FSE;
149 const header = await formatHeader(file, pkg, options);
150 debug('Header: %s', header);
151 const current = await fs.read(file, 'utf8');
152 const content = mergeHeaderWithContent(
153 header,
154 current,
155 options.customLicenseLines,
156 );
157 if (!options.dryRun) {
158 await fs.write(file, content, 'utf8');
159 } else {
160 const log = options.log || console.log;
161 log(file, header);
162 }
163 return content;
164}
165
166/**
167 * Merge header with file content

Callers 1

Calls 3

formatHeaderFunction · 0.85
mergeHeaderWithContentFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected