paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers

Home Page:https://paljs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pal g only works if the prisma.schema file is saved as LF (linux default)

Mu4all opened this issue · comments

I'm just a noob, working on windows and I had it saved in CRLF. It does not throw an error, but it only generated the graphql stuff and not the admin pieces.

Due to some wonky regexp in PrismaReader.js this fails.

    get models() {
        return this.data.match(/\n(model(\s)[\s\S]*?})\n/g);
    }
    get enums() {
        return this.data.match(/\n(enum(\s)[\s\S]*?})\n/g);
    }

What would work is (I tested it)

    get models() {
        return this.data.match(/>\r?\n(model(\s)[\s\S]*?})\r?\n/g);
    }
    get enums() {
        return this.data.match(/\r?\n(enum(\s)[\s\S]*?})\r?\n/g);
    }

please open pull request with your change