mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 12:57:46 +00:00
[cli] Add `vc build` integration test Adds a `vc build` integration test to ensure the ncc'd CLI works as expected to supplement the unit tests from #7869. Co-authored-by: Steven <steven@ceriously.com>
34 lines
838 B
JavaScript
34 lines
838 B
JavaScript
const fs = require('fs');
|
|
const util = require('util');
|
|
const isCi = require('is-ci');
|
|
|
|
const shouldWriteToFile = isCi || process.env.WRITE_LOGS_TO_FILES;
|
|
|
|
exports.logWithinTest = logWithinTest;
|
|
|
|
const dateFormat = new Intl.DateTimeFormat('en-us', {
|
|
dateStyle: 'short',
|
|
timeStyle: 'medium',
|
|
});
|
|
|
|
function logWithinTest(...inputs) {
|
|
const { testPath, currentTestName } =
|
|
typeof expect !== 'undefined' ? expect.getState() : {};
|
|
|
|
const messages = [
|
|
dateFormat.format(new Date()),
|
|
currentTestName,
|
|
...inputs,
|
|
].filter(Boolean);
|
|
const message = messages
|
|
.map(x => (typeof x === 'string' ? x : util.inspect(x)))
|
|
.join('\t');
|
|
|
|
if (shouldWriteToFile && testPath) {
|
|
const filePath = `${testPath}.artifact.log`;
|
|
fs.appendFileSync(filePath, `${message.trim()}\n`);
|
|
}
|
|
|
|
console.log(message.trim());
|
|
}
|