mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 12:57:46 +00:00
[next] Add public dir check and update tests (#5526)
* Add public dir check and update tests * De-dupe test checks a bit
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const fs = require('fs-extra');
|
||||
const { glob, getWriteableDirectory } = require('@vercel/build-utils');
|
||||
|
||||
function runAnalyze(wrapper, context) {
|
||||
@@ -11,13 +12,21 @@ function runAnalyze(wrapper, context) {
|
||||
async function runBuildLambda(inputPath) {
|
||||
const inputFiles = await glob('**', inputPath);
|
||||
const nowJsonRef = inputFiles['vercel.json'] || inputFiles['now.json'];
|
||||
expect(nowJsonRef).toBeDefined();
|
||||
|
||||
if (typeof expect !== 'undefined') {
|
||||
expect(nowJsonRef).toBeDefined();
|
||||
}
|
||||
const nowJson = require(nowJsonRef.fsPath);
|
||||
expect(nowJson.builds.length).toBe(1);
|
||||
const build = nowJson.builds[0];
|
||||
expect(build.src.includes('*')).toBeFalsy();
|
||||
|
||||
if (typeof expect !== 'undefined') {
|
||||
expect(build.src.includes('*')).toBeFalsy();
|
||||
}
|
||||
const entrypoint = build.src.replace(/^\//, ''); // strip leftmost slash
|
||||
expect(inputFiles[entrypoint]).toBeDefined();
|
||||
|
||||
if (typeof expect !== 'undefined') {
|
||||
expect(inputFiles[entrypoint]).toBeDefined();
|
||||
}
|
||||
inputFiles[entrypoint].digest =
|
||||
'this-is-a-fake-digest-for-non-default-analyze';
|
||||
const wrapper = require(build.use);
|
||||
@@ -28,7 +37,7 @@ async function runBuildLambda(inputPath) {
|
||||
config: build.config,
|
||||
});
|
||||
|
||||
const workPath = await getWriteableDirectory();
|
||||
const workPath = await fs.realpath(await getWriteableDirectory());
|
||||
const buildResult = await wrapper.build({
|
||||
files: inputFiles,
|
||||
entrypoint,
|
||||
|
||||
Reference in New Issue
Block a user