Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class PrismaMergeSchema extends Command {
itemsToRemove = itemsToRemove
.split("\n")
.filter((i: string) => i !== "")
.map((i: string) => i.trim());
.map((i: string) => i.trim())
.filter((i) => i !== "");

// Find the line inside the appropriate model
const splitStr: string[] = str.split("\n");
Expand All @@ -64,7 +65,7 @@ class PrismaMergeSchema extends Command {
[
...splitStr.map((i) => {
i = i.replace(/^\s+/, "");
if (!i.startsWith("model")) {
if (!i.startsWith("model") && !i.startsWith("generator") && !i.startsWith("datasource")) {
i = i.substring(0, i.indexOf(" "));
}
return i;
Expand Down Expand Up @@ -101,15 +102,16 @@ class PrismaMergeSchema extends Command {
linePrefix: content.substring(0, content.indexOf(" ")),
content,
};
});
})
.filter((i) => i.content !== "");

// Find the line inside the appropriate model
const splitStr = str.split("\n");

const leftTrimmed = [
...splitStr.map((i) => {
i = i.replace(/^\s+/, "");
if (!i.startsWith("model")) {
if (!i.startsWith("model") && !i.startsWith("generator") && !i.startsWith("datasource")) {
i = i.substring(0, i.indexOf(" "));
}
return i;
Expand Down