diff --git a/packages/cli/lib/cli/commands/tree.js b/packages/cli/lib/cli/commands/tree.js index 0c93af6c117..2da80136012 100644 --- a/packages/cli/lib/cli/commands/tree.js +++ b/packages/cli/lib/cli/commands/tree.js @@ -69,6 +69,7 @@ tree.handler = async function(argv) { if (argv.dependencyDefinition) { graph = await graphFromStaticFile({ filePath: argv.dependencyDefinition, + rootConfigPath: argv.config, versionOverride: argv.frameworkVersion, snapshotCache: argv.snapshotCache ?? argv.cacheMode ?? "Default", // Use cacheMode as fallback }); diff --git a/packages/cli/test/lib/cli/commands/tree.js b/packages/cli/test/lib/cli/commands/tree.js index 9d50acffb01..e08b338d236 100644 --- a/packages/cli/test/lib/cli/commands/tree.js +++ b/packages/cli/test/lib/cli/commands/tree.js @@ -719,7 +719,7 @@ test.serial("ui5 tree --dependency-definition", async (t) => { t.is(graph.graphFromPackageDependencies.callCount, 0); t.is(graph.graphFromStaticFile.callCount, 1); t.deepEqual(graph.graphFromStaticFile.getCall(0).args, [{ - filePath: fakePath, versionOverride: undefined, snapshotCache: "Default" + filePath: fakePath, rootConfigPath: undefined, versionOverride: undefined, snapshotCache: "Default" }]); t.is(t.context.consoleOutput, @@ -731,3 +731,37 @@ ${chalk.bold.underline("Extensions (0):")} ${chalk.italic("None")} `); }); + +test.serial("ui5 tree --dependency-definition --config", async (t) => { + const {argv, tree, traverseBreadthFirst, graph} = t.context; + + const fakeDepDefPath = path.join("/", "path", "to", "dependencies.yaml"); + const fakeConfigPath = path.join("/", "path", "to", "ui5-test.yaml"); + argv.dependencyDefinition = fakeDepDefPath; + argv.config = fakeConfigPath; + + traverseBreadthFirst.callsFake(async (fn) => { + await fn({ + project: { + getName: sinon.stub().returns("project1"), + getNamespace: sinon.stub().returns("test/project1"), + getVersion: sinon.stub().returns("1.0.0"), + getType: sinon.stub().returns("application"), + getRootPath: sinon.stub().returns("/home/project1"), + isFrameworkProject: sinon.stub().returns(false), + }, + dependencies: [] + }); + }); + + await tree.handler(argv); + + t.is(graph.graphFromPackageDependencies.callCount, 0); + t.is(graph.graphFromStaticFile.callCount, 1); + t.deepEqual(graph.graphFromStaticFile.getCall(0).args, [{ + filePath: fakeDepDefPath, + rootConfigPath: fakeConfigPath, + versionOverride: undefined, + snapshotCache: "Default" + }], "graphFromStaticFile got called with --config forwarded as rootConfigPath"); +});