Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function runLHCITarget(options) {
if (!options.token) throw new Error('Must provide token for LHCI target');
const api = new ApiClient({rootURL: options.serverBaseUrl, extraHeaders: options.extraHeaders});
const project = await api.findProjectByToken(options.token);
if (!project) {
throw new Error('Could not find active project with provided token');
}
const hash = getCurrentHash();
const branch = getCurrentBranch();
const ancestorHash =
branch === 'master' ? getAncestorHashForMaster() : getAncestorHashForBranch();
const build = await api.createBuild({
projectId: project.id,
lifecycle: 'unsealed',
hash,
branch,
ancestorHash,
commitMessage: getCommitMessage(hash),
author: getAuthor(hash),
avatarUrl: getAvatarUrl(hash),
externalBuildUrl: getExternalBuildUrl(),
runAt: new Date().toISOString(),
committedAt: getCommitTime(hash),
ancestorCommittedAt: ancestorHash ? getCommitTime(ancestorHash) : undefined,
});