Files
vercel/test/lib/run-build-lambda.js
Nathan Rajlich 8a68211cad [all] Rename packages to vercel and add logic to publish legacy package names to npm (#4233)
https://vercel.com/blog/zeit-is-now-vercel

* Updates all org packages from `@now` to `@vercel`
* Updates Now CLI package name from `now` to `vercel`
  * Packages contains `"bin"` entries for _both_ `vercel` and `now` in the package.json
* Updates `now-client` package name to `@vercel/client` (org scoped, for authenticity)

There is also a new `publish-legacy.sh` script which ensures that all the legacy package names (i.e. `now`, `now-client`, `@now/node`, etc.) will still be published as well.

We will remove this legacy publishing logic on Jan 1, 2021.
2020-05-05 23:43:57 +00:00

59 lines
1.5 KiB
JavaScript

const { glob, getWriteableDirectory } = require('@vercel/build-utils');
function runAnalyze(wrapper, context) {
if (wrapper.analyze) {
return wrapper.analyze(context);
}
return 'this-is-a-fake-analyze-result-from-default-analyze';
}
async function runBuildLambda(inputPath) {
const inputFiles = await glob('**', inputPath);
const nowJsonRef = inputFiles['now.json'];
expect(nowJsonRef).toBeDefined();
const nowJson = require(nowJsonRef.fsPath);
expect(nowJson.builds.length).toBe(1);
const build = nowJson.builds[0];
expect(build.src.includes('*')).toBeFalsy();
const entrypoint = build.src.replace(/^\//, ''); // strip leftmost slash
expect(inputFiles[entrypoint]).toBeDefined();
inputFiles[entrypoint].digest =
'this-is-a-fake-digest-for-non-default-analyze';
const wrapper = require(build.use);
const analyzeResult = runAnalyze(wrapper, {
files: inputFiles,
entrypoint,
config: build.config,
});
const workPath = await getWriteableDirectory();
const buildResult = await wrapper.build({
files: inputFiles,
entrypoint,
config: build.config,
workPath,
});
const { output } = buildResult;
// Windows support
if (output) {
buildResult.output = Object.keys(output).reduce(
(result, path) => ({
...result,
[path.replace(/\\/g, '/')]: output[path],
}),
{}
);
}
return {
analyzeResult,
buildResult,
workPath,
};
}
module.exports = runBuildLambda;