diff --git a/README.md b/README.md index 74327dd..51c8767 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ await main - for..in - macro the rest of the `console` library - macro the `??` operator - - tab size option - emit comments - disallow: - call expressions on arrow functions directly diff --git a/src/code-generator.ts b/src/code-generator.ts index 8414429..3a1d92f 100644 --- a/src/code-generator.ts +++ b/src/code-generator.ts @@ -83,8 +83,9 @@ export default class CodeGenerator extends StringBuilder { public constructor( private readonly sourceNode: SourceFile, - private readonly testing = false - ) { super(); } + private readonly testing = false, + tabSize = 2 + ) { super(tabSize); } public generate(): string { if (!this.testing) { diff --git a/src/string-builder.ts b/src/string-builder.ts index 22c4018..e478091 100644 --- a/src/string-builder.ts +++ b/src/string-builder.ts @@ -2,6 +2,10 @@ export default class StringBuilder { protected indentation = 0; private readonly parts: string[] = []; + public constructor( + private readonly tabSize: number + ) {} + protected get generated(): string { return this.parts.join(""); } @@ -27,6 +31,6 @@ export default class StringBuilder { } protected newLine(amount = 1): void { - this.append(("\n" + " ".repeat(this.indentation)).repeat(amount)); + this.append(("\n" + " ".repeat(this.tabSize).repeat(this.indentation)).repeat(amount)); } } \ No newline at end of file