Skip to content

Commit

Permalink
Merge pull request #235 from jaredwray/adding-in-time-execution-on-build
Browse files Browse the repository at this point in the history
adding in time execution on build
  • Loading branch information
jaredwray committed Jan 10, 2024
2 parents 9937d87 + 69ef270 commit b999131
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Ecto} from 'ecto';
import fs from 'fs-extra';
import {WritrOptions} from './options.js';
import {WritrConsole} from './console.js';
import {type GithubData, Github, type GithubOptions} from './github.js';

export type WritrData = {
Expand All @@ -22,6 +23,7 @@ export type WritrTemplates = {
export class WritrBuilder {
private readonly _options: WritrOptions = new WritrOptions();
private readonly _ecto: Ecto = new Ecto();
private readonly _console: WritrConsole = new WritrConsole();
constructor(options?: WritrOptions) {
if (options) {
this._options = options;
Expand All @@ -33,6 +35,8 @@ export class WritrBuilder {
}

public async build(): Promise<void> {
const startTime = Date.now();

// Validate the options
this.validateOptions(this.options);
// Set the site options
Expand Down Expand Up @@ -63,7 +67,11 @@ export class WritrBuilder {
// Build the robots.txt (/robots.txt)
await this.buildRobotsPage(this.options);

console.log('build');
const endTime = Date.now();

const executionTime = endTime - startTime;

this._console.log(`Build completed in ${executionTime}ms`);
}

public validateOptions(options: WritrOptions): void {
Expand Down
2 changes: 1 addition & 1 deletion test/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('WritrBuilder', () => {
await fs.remove(builder.options.outputPath);
}

expect(consoleMessage).toBe('build');
expect(consoleMessage).toContain('Build');

console.log = consoleLog;
});
Expand Down

0 comments on commit b999131

Please sign in to comment.