MCPcopy
hub / github.com/mozilla/web-ext / defaultVersionGetter

Function defaultVersionGetter

src/program.js:351–370  ·  view source on GitHub ↗
(
  absolutePackageDir,
  { globalEnv = defaultGlobalEnv } = {},
)

Source from the content-addressed store, hash-verified

349//A definition of type of argument for defaultVersionGetter
350
351export async function defaultVersionGetter(
352 absolutePackageDir,
353 { globalEnv = defaultGlobalEnv } = {},
354) {
355 if (globalEnv === 'production') {
356 log.debug('Getting the version from package.json');
357 const packageData = readFileSync(
358 path.join(absolutePackageDir, 'package.json'),
359 );
360 return JSON.parse(packageData).version;
361 } else {
362 log.debug('Getting version from the git revision');
363 // This branch is only reached during development.
364 // git-rev-sync is in devDependencies, and lazily imported using require.
365 // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916
366 // eslint-disable-next-line import/no-extraneous-dependencies
367 const git = await import('git-rev-sync');
368 return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;
369 }
370}
371
372export function throwUsageErrorIfArray(errorMessage) {
373 return (value) => {

Callers 1

test.program.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…