Skip to content

Commit

Permalink
feat(cli): add paths helper (#2729)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored May 31, 2024
1 parent 38d8927 commit a416802
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cli/services/path.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ describe('path.service', () => {
delete env.NODE_VERSION;
});

test('cachePath', () => {
expect(child.get(PathService).cachePath).toBe(
rootPath('opt/containerbase/cache'),
);
});

test('envFile', () => {
expect(child.get(PathService).envFile).toBe(rootPath('usr/local/etc/env'));
});
Expand All @@ -25,6 +31,12 @@ describe('path.service', () => {
expect(child.get(PathService).tmpDir).toBe(rootPath('tmp'));
});

test('homePath', () => {
expect(child.get(PathService).homePath).toBe(
rootPath('opt/containerbase/home'),
);
});

test('toolsPath', () => {
expect(child.get(PathService).toolsPath).toBe(
rootPath('opt/containerbase/tools'),
Expand Down
8 changes: 8 additions & 0 deletions src/cli/services/path.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export class PathService {
return join(this.installDir, 'versions');
}

get homePath(): string {
return join(this.installDir, 'home');
}

get cachePath(): string {
return join(this.installDir, 'cache');
}

constructor(@inject(EnvService) private envSvc: EnvService) {}

async createToolPath(tool: string): Promise<string> {
Expand Down

0 comments on commit a416802

Please sign in to comment.