@prisma/generator-helper
Advanced tools
Comparing version
@@ -44,4 +44,6 @@ "use strict"; | ||
test('not executable', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const generator = new GeneratorProcess_1.GeneratorProcess(path_1.default.join(__dirname, 'not-executable')); | ||
expect(generator.init()).rejects.toThrow('lacks the right chmod'); | ||
expect(() => { | ||
const generator = new GeneratorProcess_1.GeneratorProcess(path_1.default.join(__dirname, 'not-executable')); | ||
}).toThrow('is not executable'); | ||
// expect(generator.init()).rejects.toThrow('is not executable') | ||
})); | ||
@@ -59,5 +61,7 @@ test('parsing error', () => __awaiter(void 0, void 0, void 0, function* () { | ||
"defaultOutput": "default-output", | ||
"denylist": Array [ | ||
"SomeForbiddenType", | ||
], | ||
"denylists": Object { | ||
"models": Array [ | ||
"SomeForbiddenModel", | ||
], | ||
}, | ||
"prettyName": "This is a pretty pretty name", | ||
@@ -64,0 +68,0 @@ "requiresEngines": Array [ |
@@ -18,2 +18,3 @@ "use strict"; | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
@@ -31,2 +32,5 @@ let globalMessageId = 1; | ||
} | ||
if (!hasChmodX(executablePath)) { | ||
throw new Error(`${chalk_1.default.bold(executablePath)} is not executable. Please run ${chalk_1.default.greenBright(`chmod +x ${path_1.default.relative(process.cwd(), executablePath)}`)}`); | ||
} | ||
} | ||
@@ -155,2 +159,8 @@ init() { | ||
exports.GeneratorProcess = GeneratorProcess; | ||
function hasChmodX(file) { | ||
const s = fs_1.default.statSync(file); | ||
// tslint:disable-next-line | ||
const newMode = s.mode | 64 | 8 | 1; | ||
return s.mode === newMode; | ||
} | ||
//# sourceMappingURL=GeneratorProcess.js.map |
@@ -177,5 +177,8 @@ export declare namespace DMMF { | ||
defaultOutput?: string; | ||
denylist?: string[]; | ||
denylists?: { | ||
models?: string[]; | ||
fields?: string[]; | ||
}; | ||
requiresGenerators?: string[]; | ||
requiresEngines?: EngineType[]; | ||
}; |
{ | ||
"name": "@prisma/generator-helper", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -33,6 +33,8 @@ import { GeneratorProcess } from '../GeneratorProcess' | ||
test('not executable', async () => { | ||
const generator = new GeneratorProcess( | ||
path.join(__dirname, 'not-executable'), | ||
) | ||
expect(generator.init()).rejects.toThrow('lacks the right chmod') | ||
expect(() => { | ||
const generator = new GeneratorProcess( | ||
path.join(__dirname, 'not-executable'), | ||
) | ||
}).toThrow('is not executable') | ||
// expect(generator.init()).rejects.toThrow('is not executable') | ||
}) | ||
@@ -56,5 +58,7 @@ test('parsing error', async () => { | ||
"defaultOutput": "default-output", | ||
"denylist": Array [ | ||
"SomeForbiddenType", | ||
], | ||
"denylists": Object { | ||
"models": Array [ | ||
"SomeForbiddenModel", | ||
], | ||
}, | ||
"prettyName": "This is a pretty pretty name", | ||
@@ -61,0 +65,0 @@ "requiresEngines": Array [ |
@@ -5,2 +5,3 @@ import { ChildProcessByStdio, spawn } from 'child_process' | ||
import fs from 'fs' | ||
import path from 'path' | ||
import chalk from 'chalk' | ||
@@ -21,2 +22,12 @@ | ||
} | ||
if (!hasChmodX(executablePath)) { | ||
throw new Error( | ||
`${chalk.bold( | ||
executablePath, | ||
)} is not executable. Please run ${chalk.greenBright( | ||
`chmod +x ${path.relative(process.cwd(), executablePath)}`, | ||
)}`, | ||
) | ||
} | ||
} | ||
@@ -164,1 +175,8 @@ async init() { | ||
} | ||
function hasChmodX(file: string): boolean { | ||
const s = fs.statSync(file) | ||
// tslint:disable-next-line | ||
const newMode = s.mode | 64 | 8 | 1 | ||
return s.mode === newMode | ||
} |
@@ -197,5 +197,8 @@ export namespace DMMF { | ||
defaultOutput?: string | ||
denylist?: string[] | ||
denylists?: { | ||
models?: string[] | ||
fields?: string[] | ||
} | ||
requiresGenerators?: string[] | ||
requiresEngines?: EngineType[] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57526
3.1%1349
3.06%