MCPcopy Index your code
hub / github.com/payloadcms/payload / initDevAndTest

Function initDevAndTest

test/initDevAndTest.ts:16–56  ·  view source on GitHub ↗
(
  testSuiteArg: string,
  writeDBAdapter: string,
  skipGenImportMap: string,
  configFile?: string,
)

Source from the content-addressed store, hash-verified

14const runImmediately = process.argv[2]
15
16export async function initDevAndTest(
17 testSuiteArg: string,
18 writeDBAdapter: string,
19 skipGenImportMap: string,
20 configFile?: string,
21): Promise<void> {
22 const importMapPath: string = path.resolve(
23 getNextRootDir(testSuiteArg).rootDir,
24 './app/(payload)/admin/importMap.js',
25 )
26
27 try {
28 fs.writeFileSync(importMapPath, 'export const importMap = {}')
29 } catch (error) {
30 console.log('Error writing importMap.js', error)
31 }
32
33 if (writeDBAdapter === 'true') {
34 const dbAdapter: keyof typeof allDatabaseAdapters =
35 (process.env.PAYLOAD_DATABASE as keyof typeof allDatabaseAdapters) || 'mongodb'
36 generateDatabaseAdapter(dbAdapter)
37 }
38
39 if (skipGenImportMap === 'true') {
40 console.log('Done')
41 return
42 }
43
44 // Generate importMap
45 const testDir = path.resolve(dirname, testSuiteArg)
46 console.log('Generating import map for config:', testDir)
47
48 const configUrl = pathToFileURL(path.resolve(testDir, configFile ?? 'config.ts')).href
49 const config: SanitizedConfig = await (await import(configUrl)).default
50
51 process.env.ROOT_DIR = getNextRootDir(testSuiteArg).rootDir
52
53 await generateImportMap(config, { log: true, force: true })
54
55 console.log('Done')
56}
57
58if (runImmediately === 'true') {
59 const testSuiteArg = process.argv[3]

Callers 2

initDevAndTest.tsFile · 0.85
runInitFunction · 0.85

Calls 4

generateImportMapFunction · 0.90
getNextRootDirFunction · 0.85
generateDatabaseAdapterFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…