Home / Function/ prepareFilenames() — drizzle-orm Function Reference

prepareFilenames() — drizzle-orm Function Reference

Architecture documentation for the prepareFilenames() function in index.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  d2a6d85b_7d3b_7d17_794c_d2cd77de724c["prepareFilenames()"]
  c3eb904f_5390_9c0d_4b12_54d182c5f8c9["index.ts"]
  d2a6d85b_7d3b_7d17_794c_d2cd77de724c -->|defined in| c3eb904f_5390_9c0d_4b12_54d182c5f8c9
  d8e81f13_ca82_f43e_b1af_dd7ca01cbee1["prepareGenerateConfig()"]
  d8e81f13_ca82_f43e_b1af_dd7ca01cbee1 -->|calls| d2a6d85b_7d3b_7d17_794c_d2cd77de724c
  9a3b19e2_a7d5_5e85_8b45_0f77ed2556a2["prepareExportConfig()"]
  9a3b19e2_a7d5_5e85_8b45_0f77ed2556a2 -->|calls| d2a6d85b_7d3b_7d17_794c_d2cd77de724c
  a1933878_8b6f_3410_d1a4_4a23055ce7d6["preparePushConfig()"]
  a1933878_8b6f_3410_d1a4_4a23055ce7d6 -->|calls| d2a6d85b_7d3b_7d17_794c_d2cd77de724c
  28658aa5_a9ca_196c_cf25_5227ba3e8e36["serializeMySql()"]
  28658aa5_a9ca_196c_cf25_5227ba3e8e36 -->|calls| d2a6d85b_7d3b_7d17_794c_d2cd77de724c
  dd36a37c_7a7b_0f61_31c0_b6a9f9c621ef["serializePg()"]
  dd36a37c_7a7b_0f61_31c0_b6a9f9c621ef -->|calls| d2a6d85b_7d3b_7d17_794c_d2cd77de724c
  635252db_7a68_131f_350d_60c2806f943d["serializeSQLite()"]
  635252db_7a68_131f_350d_60c2806f943d -->|calls| d2a6d85b_7d3b_7d17_794c_d2cd77de724c
  89b7ba7c_6d44_6830_1256_8740e8b6838e["serializeSingleStore()"]
  89b7ba7c_6d44_6830_1256_8740e8b6838e -->|calls| d2a6d85b_7d3b_7d17_794c_d2cd77de724c
  b0ef3d06_896b_eefc_c410_dfb419673d70["error()"]
  d2a6d85b_7d3b_7d17_794c_d2cd77de724c -->|calls| b0ef3d06_896b_eefc_c410_dfb419673d70
  style d2a6d85b_7d3b_7d17_794c_d2cd77de724c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/serializer/index.ts lines 73–130

export const prepareFilenames = (path: string | string[]) => {
	if (typeof path === 'string') {
		path = [path];
	}
	const prefix = process.env.TEST_CONFIG_PATH_PREFIX || '';

	const result = path.reduce((result, cur) => {
		const globbed = glob.sync(`${prefix}${cur}`);

		globbed.forEach((it) => {
			const fileName = fs.lstatSync(it).isDirectory() ? null : Path.resolve(it);

			const filenames = fileName
				? [fileName!]
				: fs.readdirSync(it).map((file) => Path.join(Path.resolve(it), file));

			filenames
				.filter((file) => !fs.lstatSync(file).isDirectory())
				.forEach((file) => result.add(file));
		});

		return result;
	}, new Set<string>());
	const res = [...result];

	// TODO: properly handle and test
	const errors = res.filter((it) => {
		return !(
			it.endsWith('.ts')
			|| it.endsWith('.js')
			|| it.endsWith('.cjs')
			|| it.endsWith('.mjs')
			|| it.endsWith('.mts')
			|| it.endsWith('.cts')
		);
	});

	// when schema: "./schema" and not "./schema.ts"
	if (res.length === 0) {
		console.log(
			error(
				`No schema files found for path config [${
					path
						.map((it) => `'${it}'`)
						.join(', ')
				}]`,
			),
		);
		console.log(
			error(
				`If path represents a file - please make sure to use .ts or other extension in the path`,
			),
		);
		process.exit(1);
	}

	return res;
};

Domain

Subdomains

Calls

Frequently Asked Questions

What does prepareFilenames() do?
prepareFilenames() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/index.ts.
Where is prepareFilenames() defined?
prepareFilenames() is defined in drizzle-kit/src/serializer/index.ts at line 73.
What does prepareFilenames() call?
prepareFilenames() calls 1 function(s): error.
What calls prepareFilenames()?
prepareFilenames() is called by 7 function(s): prepareExportConfig, prepareGenerateConfig, preparePushConfig, serializeMySql, serializePg, serializeSQLite, serializeSingleStore.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free