Skip to content

Commit

Permalink
fix(devkit): pass filepath to ejs for include statements (#19517)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Oct 11, 2023
1 parent 1c08c8b commit b8e1500
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"@testing-library/react": "13.4.0",
"@types/cytoscape": "^3.18.2",
"@types/detect-port": "^1.3.2",
"@types/ejs": "3.1.2",
"@types/eslint": "~8.44.2",
"@types/express": "4.17.14",
"@types/flat": "^5.0.1",
Expand Down
6 changes: 4 additions & 2 deletions packages/devkit/src/generators/generate-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function generateFiles(
target: string,
substitutions: { [k: string]: any }
): void {
const ejs = require('ejs');
const ejs: typeof import('ejs') = require('ejs');

const files = allFilesInDir(srcFolder);
if (files.length === 0) {
Expand All @@ -56,7 +56,9 @@ export function generateFiles(
} else {
const template = readFileSync(filePath, 'utf-8');
try {
newContent = ejs.render(template, substitutions, {});
newContent = ejs.render(template, substitutions, {
filename: filePath,
});
} catch (e) {
logger.error(`Error in ${filePath.replace(`${tree.root}/`, '')}:`);
throw e;
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit b8e1500

@vercel
Copy link

@vercel vercel bot commented on b8e1500 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.