(
absolutePackageDir,
{ globalEnv = defaultGlobalEnv } = {},
)
| 349 | //A definition of type of argument for defaultVersionGetter |
| 350 | |
| 351 | export 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 | |
| 372 | export function throwUsageErrorIfArray(errorMessage) { |
| 373 | return (value) => { |
no outgoing calls
no test coverage detected
searching dependent graphs…