Adjust assert usage (#4966)

* Adjust assert usage

* Adjust assert

* Apply suggestions from code review
This commit is contained in:
Jaco
2022-06-20 20:37:17 +03:00
committed by GitHub
parent 94c5c025a9
commit 3a8b1c5683
16 changed files with 146 additions and 80 deletions
+3 -3
View File
@@ -4,8 +4,6 @@
import fs from 'fs';
import path from 'path';
import { assert } from '@polkadot/util';
import { packageInfo } from '../packageInfo';
export function writeFile (dest: string, generator: () => string, noLog?: boolean): void {
@@ -35,7 +33,9 @@ export function readTemplate (template: string): string {
.map((p) => path.join(rootDir, p, `${template}.hbs`))
.find((p) => fs.existsSync(p));
assert(file, `Unable to locate ${template}.hbs from ${rootDir}`);
if (!file) {
throw new Error(`Unable to locate ${template}.hbs from ${rootDir}`);
}
return fs.readFileSync(file).toString();
}