@@ -17,6 +17,7 @@ export interface InitializeArgs {
1717 verbosityLevel ?: number ;
1818 transformProject ?: ( project : Project ) => Project | Promise < Project > ;
1919 allowEmptyProject ?: boolean ;
20+ forceEmptyProject ?: boolean ;
2021}
2122
2223export interface InitializationResult {
@@ -30,14 +31,10 @@ export class PluginInitOrchestrator {
3031 args : InitializeArgs ,
3132 reporter : Reporter ,
3233 ) : Promise < InitializationResult > {
33- const codifyPath = await PluginInitOrchestrator . resolveCodifyRootPath ( args , reporter ) ;
34-
35- let project = await PluginInitOrchestrator . parse (
36- codifyPath ,
34+ const project = await PluginInitOrchestrator . parseProject (
35+ args ,
36+ reporter
3737 ) ;
38- if ( args . transformProject ) {
39- project = await args . transformProject ( project ) ;
40- }
4138
4239 ctx . subprocessStarted ( SubProcessName . INITIALIZE_PLUGINS )
4340 const pluginManager = new PluginManager ( ) ;
@@ -47,18 +44,28 @@ export class PluginInitOrchestrator {
4744 return { resourceDefinitions, pluginManager, project } ;
4845 }
4946
50- private static async parse (
51- fileOrDir : string | undefined ,
47+ private static async parseProject (
48+ args : InitializeArgs ,
49+ reporter : Reporter ,
5250 ) : Promise < Project > {
51+ if ( args . forceEmptyProject ) {
52+ return Project . empty ( ) ;
53+ }
54+
55+ const codifyPath = await PluginInitOrchestrator . resolveCodifyRootPath ( args , reporter ) ;
5356 ctx . subprocessStarted ( SubProcessName . PARSE ) ;
5457
55- const project = fileOrDir
56- ? await CodifyParser . parse ( fileOrDir )
58+ const project = codifyPath
59+ ? await CodifyParser . parse ( codifyPath )
5760 : Project . empty ( )
5861
5962 ctx . subprocessFinished ( SubProcessName . PARSE ) ;
6063
61- return project
64+ if ( args . transformProject ) {
65+ return args . transformProject ( project ) ;
66+ }
67+
68+ return project ;
6269 }
6370
6471 /** Resolve the root codify file to run.
0 commit comments