export function getArtifactRepository()

in prototype/infra/lib/stack/root/PipelineStack/npm-registry.ts [26:52]


export function getArtifactRepository (): string | undefined {
	const npmrcPath = findUp('.npmrc', { cwd: __dirname })

	if (npmrcPath) {
		try {
			const npmrc = parseINI(fs.readFileSync(npmrcPath, { encoding: 'utf-8' }))

			const repositoryName = (ENGAGEMENT_REGISTRY_PATTERN.exec(
				npmrc.registry || '',
			) || [])[1]

			if (repositoryName == null) {
				console.info('Could not determine engagement repository', __dirname)
			}

			return repositoryName
		} catch (error) {
			console.warn(
				'Could not determine engagement repository',
				__dirname,
				error,
			)
		}
	}

	return undefined
}