Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse committed Sep 8, 2024
1 parent 7086caf commit 69a60d6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 276 deletions.
21 changes: 2 additions & 19 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fs from 'fs';
import util from 'util';
import fetch from 'node-fetch';
import { connectorsToHostFile } from './utils';

const mkdir = util.promisify(fs.mkdir);
const writeFile = util.promisify(fs.writeFile);
Expand Down Expand Up @@ -73,26 +74,8 @@ async function dumpConnectors() {

async function dumpHostfile() {
const connectors = (await import(`./${moduleFile}`)).default as any[];

const result = connectors
.filter((connector) => 'matches' in connector)
.map((connector) => {
const label = connector.label;
const urls = connector.matches.map(function (match) {
match = match.replace(/\*:\/\/(\*\.)?/, '');
match = match.replace(/\/\*.*/, '');
match = match.replace(/\.\*/, '.tld');
match = match.replace(/\/.+/, '');
return match;
});

return `# ${label}\n${urls.join('\n')}`;
});

const contents = result.join('\n\n');

const contents = connectorsToHostFile(connectors);
console.log(contents);

await writeFile(hostFile, contents);
}

Expand Down
Loading

0 comments on commit 69a60d6

Please sign in to comment.