paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
679 stars 55 forks source link

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

Open Mu4all opened 1 year ago

Mu4all commented 1 year ago

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);
    }
AhmedElywa commented 10 months ago

please open pull request with your change