experimental-prisma-webpack-plugin
Advanced tools
Comparing version 0.0.2 to 0.0.3
20
index.js
@@ -6,12 +6,14 @@ // @ts-check | ||
// if client is bundled this gets its output path | ||
// when client is bundled this gets its output path | ||
// regex works both on escaped and non-escaped code | ||
const prismaDirRegex = /\\?"?output\\?"?:\s*{(?:\\n?|\s)*\\?"?value\\?"?:(?:\\n?|\s)*\\?"(.*?)\\?",(?:\\n?|\s)*\\?"?fromEnvVar\\?"?/g | ||
function getPrismaDir(from) { | ||
try { | ||
return path.dirname(require.resolve('.prisma/client', { paths: [from] })) | ||
} catch (e) {} | ||
async function getPrismaDir(from) { | ||
// if we can find schema.prisma in the path, we are done | ||
if (await fs.stat(path.join(from, 'schema.prisma')).catch(() => false)) { | ||
return from | ||
} | ||
return from | ||
// otherwise we need to find the generated prisma client | ||
return path.dirname(require.resolve('.prisma/client', { paths: [from] })) | ||
} | ||
@@ -21,3 +23,3 @@ | ||
async function getPrismaFiles(from) { | ||
const prismaDir = getPrismaDir(from) | ||
const prismaDir = await getPrismaDir(from) | ||
const filterRegex = /schema\.prisma|.*?engine.*?/ | ||
@@ -64,3 +66,3 @@ const prismaFiles = await fs.readdir(prismaDir) | ||
for (const match of sourceContents.matchAll(prismaDirRegex)) { | ||
const prismaDir = getPrismaDir(match[1]) | ||
const prismaDir = await getPrismaDir(match[1]) | ||
const prismaFiles = await getPrismaFiles(match[1]) | ||
@@ -132,2 +134,2 @@ | ||
module.exports = { PrismaPlugin } | ||
module.exports = { PrismaPlugin } |
{ | ||
"name": "experimental-prisma-webpack-plugin", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Ensures that your Prisma files are copied", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,4 @@ # Experimental Prisma Webpack Plugin | ||
```js | ||
const { PrismaPlugin } = require('experimental-prisma-webpack-plugin') | ||
module.exports = { | ||
@@ -24,2 +26,4 @@ output: 'standalone', | ||
```js | ||
const { PrismaPlugin } = require('experimental-prisma-webpack-plugin') | ||
module.exports = { | ||
@@ -26,0 +30,0 @@ plugins: [new PrismaPlugin()] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5444
108
31