const Axios = require('axios');
const { writeFile, existsSync, mkdirSync } = require('fs');
const logUpdate = require('log-update');

const startSpinner = text => {
  const frames = ['-', '\\', '|', '/'];
  let i = 0;

  console.log('');

  logUpdate(`${frames[0]} ${text}`);

  const interval = setInterval(() => {
    const frame = frames[(i = ++i % frames.length)];

    logUpdate(`${frame} ${text}`);
  }, 80);

  return {
    stop: () => {
      clearInterval(interval);
      logUpdate(`Done!`);
    },
  };
};

if (!existsSync('filters')) {
  mkdirSync('filters');
}

if (!existsSync('filters/default.dat')) {
  let spinner = startSpinner('Downloading default filter cache...');

  Axios.request({
    url: 'https://wexond.net/filters/default.dat',
    responseType: 'arraybuffer',
    method: 'get',
  }).then(({ data }) => {
    spinner.stop();

    spinner = startSpinner('Writing cache to ./filters/default.dat...');

    writeFile('filters/default.dat', data, err => {
      if (err) return console.error(err);
      spinner.stop();
    });
  });
}

@@ -88,433 +88,8 @@
 s');
-%0Aconst logUpdate = require('log-update');%0A%0Aconst startSpinner = text =%3E %7B%0A  const frames = %5B'-', '%5C%5C', '%7C', '/'%5D;%0A  let i = 0;%0A%0A  console.log('');%0A%0A  logUpdate(%60$%7Bframes%5B0%5D%7D $%7Btext%7D%60);%0A%0A  const interval = setInterval(() =%3E %7B%0A    const frame = frames%5B(i = ++i %25 frames.length)%5D;%0A%0A    logUpdate(%60$%7Bframe%7D $%7Btext%7D%60);%0A  %7D, 80);%0A%0A  return %7B%0A    stop: () =%3E %7B%0A      clearInterval(interval);%0A      logUpdate(%60Done!%60);%0A    %7D,%0A  %7D;%0A%7D;
 %0A%0Aif
@@ -191,34 +191,19 @@
 %7B%0A  
-let spinner = startSpinner
+console.log
 ('Do
@@ -395,51 +395,19 @@
     
-spinner.stop();%0A%0A    spinner = startSpinner
+console.log
 ('Wr
@@ -548,30 +548,8 @@
 r);%0A
-      spinner.stop();%0A
     

remove some redundant logs