Select Git revision
-
Reiter, Christoph authored
Instead of going through the rollup plugin. Turns out the rollup plugin api shouldn't be used outside of rollup. Ideally this should give us the same path resolution anyway, even though it's potentially a different implementation.
Reiter, Christoph authoredInstead of going through the rollup plugin. Turns out the rollup plugin api shouldn't be used outside of rollup. Ideally this should give us the same path resolution anyway, even though it's potentially a different implementation.
rollup.utils.js 1000 B
import path from 'path';
import url from 'url';
import child_process from 'child_process';
import resolve from '@rollup/plugin-node-resolve';
export function getBuildInfo(build) {
let remote = child_process.execSync('git config --get remote.origin.url').toString().trim();
let commit = child_process.execSync('git rev-parse --short HEAD').toString().trim();
let parsed = url.parse(remote);
let newPath = parsed.path.slice(0, parsed.path.lastIndexOf('.'));
let newUrl = parsed.protocol + '//' + parsed.host + newPath + '/commit/' + commit;
return {
info: commit,
url: newUrl,
time: new Date().toISOString(),
env: build
}
}
export async function getPackagePath(packageName, assetPath) {
const r = resolve();
const id = (await r.resolveId(packageName)).id;
const packageInfo = r.getPackageInfoForId(id);
const fullAssetPath = path.join(packageInfo.root, assetPath);
return path.relative(process.cwd(), fullAssetPath);
}