Skip to content

Commit

Permalink
feature: Implement incomplete main script
Browse files Browse the repository at this point in the history
  • Loading branch information
youthfulhps committed Aug 21, 2023
1 parent 3c4e876 commit 7470209
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
import { scrapRawScript } from '~/helpers/scraper';
import { format } from 'prettier';
import { scrapRawScript } from '~/helpers/parser';
import { parsers as babelParsers } from 'prettier/parser-babel';
import { parsers as typescriptParsers } from 'prettier/parser-typescript';

import { printers } from './helpers/printer';

export const parsers: { [parserName: string]: any } = {
babel: {
...babelParsers.babel,
astFormat: 'babel-ast',
},
typescript: {
...typescriptParsers.typescript,
astFormat: 'typescript-ast',
},
};

const myCustomPlugin = {
parsers,
printers,
astFormat: 'estree',
};

export default (async () => {
const args = process.argv.slice(2);

if (args[0] === '--target') {
const rawScript = await scrapRawScript(args[1]);
console.log(rawScript);

const formattedScript = format(rawScript, {
plugins: [myCustomPlugin],
});
console.log(formattedScript);
}
})();

0 comments on commit 7470209

Please sign in to comment.