Skip to content

Commit

Permalink
further fixes to getting rootWorkingDirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonah Iden committed Aug 31, 2022
1 parent cf87346 commit 5f17379
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion typefox-test/src/browser/typefox-test-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuMo
import { WorkspaceService } from '@theia/workspace/lib/browser'
import { CommonMenus, FrontendApplication, FrontendApplicationContribution } from '@theia/core/lib/browser';
import { IDependencyVersionCheckServer } from "../common/dependency-version-checker-protocoll";
import URI from '@theia/core/lib/common/uri';


export const dependencyVersionCheckCommand: Command = {
Expand All @@ -19,7 +20,9 @@ export class TypefoxTestCommandContribution implements CommandContribution {
registerCommands(registry: CommandRegistry): void {
registry.registerCommand(dependencyVersionCheckCommand, {
execute: async () => {
const mismatches = await this.depCheckServer.analyzeDependencies(await this.workspaceService.tryGetRoots().map(r => r.resource.toString()));
const rootPaths = await this.workspaceService.tryGetRoots().map(r => decodeURIComponent(r.resource.toString()));
console.log(rootPaths)
const mismatches = await this.depCheckServer.analyzeDependencies(rootPaths);
console.log("mismatches recieved");
console.log(mismatches);
}
Expand Down
12 changes: 10 additions & 2 deletions typefox-test/src/node/dependency-version-checker-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IDependencyVersionCheckServer } from "../common/dependency-version-chec
import * as fs from 'fs';
import * as toml from 'toml'
import { FileUri } from '@theia/core/lib/node/file-uri';
import URI from "@theia/core/lib/common/uri";


@injectable()
Expand All @@ -16,8 +17,7 @@ export class DependencyVersionCheckerServer implements IDependencyVersionCheckSe
* analyzes the dependencies from the cargo.toml and returns a list of mismatches
*/
async analyzeDependencies(rootPaths: string[]): Promise<string[]> {
// this path is hardcoded right now for my local test workspace because i couldn't figure out where to get the acutal path from
const cargoTomlFiles: string[] = await this.fileSearchService.find("cargo.toml", {rootUris: rootPaths});
const cargoTomlFiles: string[] = await this.fileSearchService.find("cargo.toml", {rootUris: rootPaths.map(r => this.uriToStringPath(r))});
const allDependencies: Dependency[] = []
for(let path of cargoTomlFiles) {
const tomlData = toml.parse(await this.getFileContent(path));
Expand Down Expand Up @@ -64,6 +64,14 @@ export class DependencyVersionCheckerServer implements IDependencyVersionCheckSe
return mismatches;
}

private uriToStringPath(uri: string): string {
let uriPath = new URI(uri).path.toString();
if(uriPath.startsWith("/")) {
uriPath = uriPath.substring(1);
}
return uriPath;
}


}

Expand Down

0 comments on commit 5f17379

Please sign in to comment.