feat(devkit): improve logging of ejs errors (#5422)

ISSUES CLOSED: #5318
This commit is contained in:
Juri Strumpflohner 2021-04-22 01:09:40 +02:00 committed by GitHub
parent 8f7d959364
commit 90b83dab7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { Tree } from '@nrwl/tao/src/shared/tree';
import { join, relative } from 'path';
import { logger } from '@nrwl/tao/src/shared/logger';
const binaryExts = new Set([
// // Image types originally from https://github.com/sindresorhus/image-type/blob/5541b6a/index.js
@ -74,7 +75,12 @@ export function generateFiles(
newContent = fs.readFileSync(filePath);
} else {
const template = fs.readFileSync(filePath).toString();
newContent = ejs.render(template, substitutions, {});
try {
newContent = ejs.render(template, substitutions, {});
} catch (e) {
logger.error(`Error in ${filePath.replace(`${host.root}/`, '')}:`);
throw e;
}
}
host.write(computedPath, newContent);