Skip to content

Commit

Permalink
remove ast dir after docgen
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyace84 committed Jan 25, 2023
1 parent 2aaa9f9 commit 108d72c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ast-builder/compile-ast.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import fs from 'fs';
import { execSync } from 'child_process';
import { Config } from '../config';
import { getAstsFromSources, getContractsList } from './getters';
import path from 'path';

/**
* It takes the config object, gets a list of contracts, and then compiles the AST for each contract
* @param {Config} config - The configuration object that we created earlier.
*/
export const compileAst = async (config: Config) => {
const contracts = getContractsList(config.sourcesDir!);

if (fs.existsSync(config.astOutputDir!)) {
fs.rm(path.resolve(config.root!, config.astOutputDir!), () => {});
}

contracts.forEach(contract => {
execSync(
`${config.compilerPath} --ast-compact-json $PWD/${config.sourcesDir}/${contract} --output-dir=$PWD/${config.astOutputDir}`,
Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ export async function main(
await fs.mkdir(path.dirname(outputFile), { recursive: true });
await fs.writeFile(outputFile, contents);
}

await fs.rm(path.resolve(config.root, config.astOutputDir), {
recursive: true,
});
}

0 comments on commit 108d72c

Please sign in to comment.