Skip to content

Commit f7768ab

Browse files
committed
Improve error further
1 parent 8c0ad1b commit f7768ab

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

__tests__/__snapshots__/include.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`compiles an included file, and won't get stuck in an infinite include loop 1`] = `
4-
"Circular include detected - '~/migrations/fixtures/foo.sql' is included again! Trace:
4+
"Circular include detected - '~/migrations/fixtures/foo.sql' is included again! Import statement: \`--!include foo.sql\`; trace:
55
~/migrations/fixtures/foo.sql
66
~/migrations/current.sql"
77
`;

src/migration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export async function compileIncludes(
154154
// Go through these matches and resolve their full paths, checking they are allowed
155155
const sqlPathByRawSqlPath = Object.create(null) as Record<string, string>;
156156
for (const match of matches) {
157-
const [, rawSqlPath] = match;
157+
const [line, rawSqlPath] = match;
158158
const sqlPath = await realpathOrNull(`${fixturesPath}/${rawSqlPath}`);
159159

160160
if (!sqlPath) {
@@ -165,7 +165,7 @@ export async function compileIncludes(
165165

166166
if (processedFiles.has(sqlPath)) {
167167
throw new Error(
168-
`Circular include detected - '${sqlPath}' is included again! Trace:\n ${[...processedFiles].reverse().join("\n ")}`,
168+
`Circular include detected - '${sqlPath}' is included again! Import statement: \`${line}\`; trace:\n ${[...processedFiles].reverse().join("\n ")}`,
169169
);
170170
}
171171

0 commit comments

Comments
 (0)