summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/src/snowpack-logger.ts19
-rw-r--r--packages/astro/test/helpers.js2
-rw-r--r--packages/astro/test/snowpack-log.test.js16
3 files changed, 17 insertions, 20 deletions
diff --git a/packages/astro/src/snowpack-logger.ts b/packages/astro/src/snowpack-logger.ts
index 0240e6c55..1eccb9252 100644
--- a/packages/astro/src/snowpack-logger.ts
+++ b/packages/astro/src/snowpack-logger.ts
@@ -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);
});
-} \ No newline at end of file
+}
diff --git a/packages/astro/test/helpers.js b/packages/astro/test/helpers.js
index 637fd5b37..68af678df 100644
--- a/packages/astro/test/helpers.js
+++ b/packages/astro/test/helpers.js
@@ -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));
-} \ No newline at end of file
+}
diff --git a/packages/astro/test/snowpack-log.test.js b/packages/astro/test/snowpack-log.test.js
index 9bde02b19..bd39b5f43 100644
--- a/packages/astro/test/snowpack-log.test.js
+++ b/packages/astro/test/snowpack-log.test.js
@@ -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__]);