[ci] yarn format

This commit is contained in:
matthewp 2021-06-07 18:26:17 +00:00 committed by GitHub Actions
parent b1364afbae
commit cb3ff36105
3 changed files with 17 additions and 20 deletions

View file

@ -4,31 +4,28 @@ function verboseLogging() {
return process.argv.includes('--verbose');
}
const onceMessages = [
'Ready!',
'watching for file changes'
].map(str => new RegExp(`\\[snowpack\\](.*?)${str}`));
const onceMessages = ['Ready!', 'watching for file changes'].map((str) => new RegExp(`\\[snowpack\\](.*?)${str}`));
export function configureSnowpackLogger(logger: typeof snowpackLogger) {
const messageCache = new Set<string>();
if(verboseLogging()) {
if (verboseLogging()) {
logger.level = 'debug';
}
logger.on('info', message => {
logger.on('info', (message) => {
// Cache messages that should only be shown once.
// This is due to having 2 snowpack instances. Once that is removed we can
// get rid of this workaround.
if(messageCache.has(message)) {
if (messageCache.has(message)) {
return;
}
const shouldBeCached = onceMessages.some(exp => exp.test(message));
if(shouldBeCached) {
messageCache.add(message);
const shouldBeCached = onceMessages.some((exp) => exp.test(message));
if (shouldBeCached) {
messageCache.add(message);
}
console.log(message);
});
}
}

View file

@ -98,4 +98,4 @@ export function runDevServer(root, additionalArgs = []) {
export async function clearCache() {
const cacheDir = new URL('../../../node_modules/.cache', import.meta.url);
await del(fileURLToPath(cacheDir));
}
}

View file

@ -4,7 +4,7 @@ import { clearCache, runDevServer } from './helpers.js';
import isWindows from 'is-windows';
// For some reason Windows isn't getting anything from stdout in this test, not sure why.
if(!isWindows()) {
if (!isWindows()) {
const SnowpackLogging = suite('snowpack logging');
const MAX_TEST_TIME = 10000; // max time this test suite may take
@ -12,7 +12,7 @@ if(!isWindows()) {
const exp = new RegExp(message, 'g');
let count = 0;
let res;
while(res = exp.exec(stdout)) {
while ((res = exp.exec(stdout))) {
count++;
}
return count;
@ -21,7 +21,7 @@ if(!isWindows()) {
const root = new URL('./fixtures/astro/basic/', import.meta.url);
const timers = {};
let runError = null;
SnowpackLogging.before(async context => {
SnowpackLogging.before(async (context) => {
await clearCache();
let importantMessages = 0;
@ -35,20 +35,20 @@ if(!isWindows()) {
if (/Server started/.test(chunk)) {
importantMessages++;
}
if(/Ready/.test(chunk)) {
if (/Ready/.test(chunk)) {
importantMessages++;
}
if(/watching for file changes/.test(chunk)) {
if (/watching for file changes/.test(chunk)) {
importantMessages++;
}
if(importantMessages === 3) {
if (importantMessages === 3) {
break;
}
}
context.stdout = stdout;
process.kill();
} catch(err) {
} catch (err) {
console.error(err);
runError = runError;
}
@ -70,7 +70,7 @@ if(!isWindows()) {
SnowpackLogging('Logs [waiting for file changes] once', ({ stdout }) => {
assert.equal(numberOfEntries(stdout, 'watching for file changes'), 1);
})
});
SnowpackLogging.after.each(({ __test__ }) => {
clearTimeout(timers[__test__]);