Skip to content

Commit

Permalink
fix(core): fall back to root if source root null (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Apr 5, 2022
1 parent 035675e commit 53bdc17
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/generators/restore/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default async function (
dotnetClient = new DotNetClient(dotnetFactory()),
) {
const projects = await getNxDotnetProjects(host);
for (const project of projects.values()) {
const projectFiles = getProjectFilesForProject(host, project);
for (const [projectName, project] of projects.entries()) {
const projectFiles = getProjectFilesForProject(host, project, projectName);
for (const file of projectFiles) {
dotnetClient.restorePackages(file);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/generators/sync/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export default async function (host: Tree) {
const projects = await getNxDotnetProjects(host);

for (const [projectName, configuration] of projects.entries()) {
const projectFiles = getProjectFilesForProject(host, configuration);
const projectFiles = getProjectFilesForProject(
host,
configuration,
projectName,
);
for (const f of projectFiles) {
const xmldoc = readXml(host, f);
console.log(`Scanning packages for ${projectName} (${f})`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export async function updateDependencyVersions(
) {
const projects = await getNxDotnetProjects(host);
for (const [projectName, configuration] of projects.entries()) {
const projectFiles = getProjectFilesForProject(host, configuration);
const projectFiles = getProjectFilesForProject(
host,
configuration,
projectName,
);
for (const f of projectFiles) {
const xmldoc = readXml(host, f);
let updateFile = false;
Expand Down
7 changes: 4 additions & 3 deletions packages/utils/src/lib/utility-functions/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ export async function getNxDotnetProjects(
export function getProjectFilesForProject(
host: Tree,
project: ProjectConfiguration | undefined,
projectName: string,
) {
if (!project?.sourceRoot) {
throw new Error('Unable to read source root for project!');
if (!project?.sourceRoot && !project?.root) {
throw new Error(`Unable to read source root for project ${projectName}`);
}
return host
.children(project.sourceRoot)
.children(project.sourceRoot ?? project.root)
.filter((x) => x.endsWith('proj'))
.map((x) => `${project.sourceRoot}/${x}`);
}
Expand Down

0 comments on commit 53bdc17

Please sign in to comment.