UNPKG

@favware/cliff-jumper

Version:

A small CLI tool to create a semantic release and git-cliff powered Changelog

42 lines 1.65 kB
import { packageCwd } from '#lib/constants'; import { fileExists } from '#lib/file-exists'; import { doActionAndLog, getGitRootDirection } from '#lib/utils'; import { filterNullish, isNullishOrEmpty } from '@sapphire/utilities'; import { execa } from 'execa'; import { join } from 'node:path'; export async function stageFiles(options, packageManagerUsed) { const lockfilePath = await getLockFilePath(options, packageManagerUsed); return doActionAndLog('Staging package.json and changelog file', async () => { if (!options.dryRun) { await execa('git', ['add', 'package.json', options.changelogPrependFile ?? './CHANGELOG.md', lockfilePath || null].filter(filterNullish)); } }); } async function getLockFilePath(options, packageManagerUsed) { const lockfile = resolveLockfile(options, packageManagerUsed); if (!isNullishOrEmpty(lockfile)) { const repositoryRootDirectory = await getGitRootDirection(); const resolvedLockfilePath = join(packageCwd, repositoryRootDirectory, lockfile); const lockfileExists = await fileExists(resolvedLockfilePath); if (lockfileExists) { return resolvedLockfilePath; } } return ''; } function resolveLockfile(options, packageManagerUsed) { if (!options.install) return ''; switch (packageManagerUsed) { case 'pnpm': return 'pnpm-lock.yaml'; case 'yarn-v1': case 'yarn-v2': case 'yarn-v3': case 'yarn-v4': return 'yarn.lock'; default: return 'package-lock.json'; } } //# sourceMappingURL=stage-files.js.map