|
1 | 1 | import { CE_DEFAULT_VALUE } from '#/configs/const-enum/CE_DEFAULT_VALUE'; |
2 | 2 | import type { ICommonOption } from '#/configs/interfaces/ICommonOption'; |
| 3 | +import type { IDocumentOption } from '#/configs/interfaces/IDocumentOption'; |
3 | 4 | import { getCwd } from '#/configs/modules/getCwd'; |
4 | 5 | import { container } from '#/modules/containers/container'; |
5 | 6 | import { SymbolLogger } from '#/modules/containers/keys/SymbolLogger'; |
6 | 7 | import { betterMkdir } from '#/modules/files/betterMkdir'; |
7 | 8 | import { getGlobFiles } from '#/modules/files/getGlobFiles'; |
8 | | -import { getOutputDirectory } from '#/modules/files/getOutputDirectory'; |
| 9 | +import { getTemplateDirPath } from '#/modules/files/getTemplateDirPath'; |
9 | 10 | import type { Logger } from '#/modules/loggers/Logger'; |
10 | 11 | import { createLogger } from '#/modules/loggers/createLogger'; |
11 | 12 | import { defaultExclude } from '#/modules/scopes/defaultExclude'; |
12 | | -import { getTemplatePath } from '#/templates/modules/getTemplatePath'; |
| 13 | +import { getTemplateModulePath } from '#/templates/modules/getTemplateModulePath'; |
13 | 14 | import { Glob } from 'glob'; |
14 | 15 | import { isError } from 'my-easy-fp'; |
15 | 16 | import { getDirname, startSepRemove } from 'my-node-fp'; |
16 | 17 | import fs from 'node:fs'; |
17 | 18 | import pathe from 'pathe'; |
18 | 19 |
|
19 | | -export async function ejecting(option: Pick<ICommonOption, 'output' | 'showLogo'>, logging?: boolean) { |
| 20 | +export async function ejecting( |
| 21 | + option: Pick<ICommonOption & IDocumentOption, 'showLogo' | 'templatePath'>, |
| 22 | + logging?: boolean, |
| 23 | +) { |
20 | 24 | createLogger(logging); |
21 | 25 | const logger = container.resolve<Logger>(SymbolLogger); |
22 | 26 |
|
23 | 27 | try { |
24 | | - const outputDirPath = await getOutputDirectory(option, getCwd(process.env)); |
25 | | - const originTemplateDirPath = await getTemplatePath(CE_DEFAULT_VALUE.TEMPLATES_PATH); |
| 28 | + const templateDirPath = await getTemplateDirPath(option, getCwd(process.env)); |
| 29 | + const originTemplateDirPath = await getTemplateModulePath(CE_DEFAULT_VALUE.TEMPLATES_PATH); |
26 | 30 | const targetTemplateDirPath = |
27 | | - option.output == null ? pathe.join(outputDirPath, CE_DEFAULT_VALUE.TEMPLATES_PATH) : outputDirPath; |
| 31 | + option.templatePath == null ? pathe.join(templateDirPath, CE_DEFAULT_VALUE.TEMPLATES_PATH) : templateDirPath; |
28 | 32 |
|
29 | | - logger.info('Output directory: ', targetTemplateDirPath); |
| 33 | + logger.info('Template directory: ', targetTemplateDirPath); |
30 | 34 |
|
31 | 35 | const originTemplateGlobPaths = new Glob(pathe.join(originTemplateDirPath, `**`, '*.eta'), { |
32 | 36 | absolute: true, |
|
0 commit comments