Skip to content

Commit

Permalink
Refactor drizzle plugin to use new entry; protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Sep 26, 2023
1 parent e1ab0c6 commit a8dea3f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/plugins/drizzle/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { _glob } from '../../util/glob.js';
import { timerify } from '../../util/Performance.js';
import { hasDependency, load } from '../../util/plugin.js';
import { toEntryPattern } from '../../util/protocols.js';
import type { DrizzleConfig } from './types.js';
import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';

Expand All @@ -15,12 +15,10 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['drizzle.config.{ts,js,json}'];

const findDrizzleDependencies: GenericPluginCallback = async (configFilePath, { cwd }) => {
const findDrizzleDependencies: GenericPluginCallback = async configFilePath => {
const config: DrizzleConfig = await load(configFilePath);
if (!config || !config.schema) return [];
const patterns = Array.isArray(config.schema) ? config.schema : [config.schema];
const paths = await _glob({ cwd, patterns });
return paths;
return [config.schema].flat().map(toEntryPattern);
};

export const findDependencies = timerify(findDrizzleDependencies);

0 comments on commit a8dea3f

Please sign in to comment.