e2e-test: update to provide version lookup helper to template

This commit is contained in:
Patrik Oldsberg
2020-10-27 19:12:16 +01:00
parent 0efbdfbbb8
commit 24c0570082
+17 -5
View File
@@ -84,11 +84,23 @@ async function buildDistWorkspace(workspaceName: string, rootDir: string) {
const path = paths.resolveOwnRoot(pkgJsonPath);
const pkgTemplate = await fs.readFile(path, 'utf8');
const { dependencies = {}, devDependencies = {} } = JSON.parse(
handlebars.compile(pkgTemplate)({
version: '0.0.0',
privatePackage: true,
scopeName: '@backstage',
}),
handlebars.compile(pkgTemplate)(
{
privatePackage: true,
scopeName: '@backstage',
},
{
helpers: {
version(name: string) {
const pkg = require(`${name}/package.json`);
if (!pkg) {
throw new Error(`No version available for package ${name}`);
}
return pkg.version;
},
},
},
),
);
Array<string>()