paljs/prisma-tools

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

Mu4all opened this issue · 1 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