Skip to content

Commit

Permalink
refactor: move constructor injections (#2133)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Feb 5, 2024
1 parent db3bd5a commit 1c6f0aa
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
8 changes: 7 additions & 1 deletion src/cli/prepare-tool/prepare-tool-base.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { injectable } from 'inversify';
import { inject, injectable } from 'inversify';
import { EnvService, PathService } from '../services';

@injectable()
export abstract class PrepareToolBaseService {
abstract readonly name: string;

constructor(
@inject(PathService) protected readonly pathSvc: PathService,
@inject(EnvService) protected readonly envSvc: EnvService,
) {}

abstract execute(): Promise<void> | void;

toString(): string {
Expand Down
4 changes: 0 additions & 4 deletions src/cli/tools/dart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import {
export class PrepareDartService extends PrepareToolBaseService {
readonly name = 'dart';

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

async execute(): Promise<void> {
await fs.mkdir(`${this.envSvc.home}/.dart`);
await fs.writeFile(
Expand Down
4 changes: 0 additions & 4 deletions src/cli/tools/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import {
export class PrepareDockerService extends PrepareToolBaseService {
readonly name = 'docker';

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

async execute(): Promise<void> {
await execa('groupadd', ['-g', '999', 'docker']);
await execa('usermod', ['-aG', 'docker', this.envSvc.userName]);
Expand Down
6 changes: 3 additions & 3 deletions src/cli/tools/dotnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class PrepareDotnetService extends PrepareToolBaseService {
readonly name = 'dotnet';

constructor(
@inject(EnvService) private readonly envSvc: EnvService,
@inject(EnvService) envSvc: EnvService,
@inject(AptService) private readonly aptSvc: AptService,
@inject(PathService) private readonly pathSvc: PathService,
@inject(PathService) pathSvc: PathService,
) {
super();
super(pathSvc, envSvc);
}

async execute(): Promise<void> {
Expand Down
4 changes: 0 additions & 4 deletions src/cli/tools/flutter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import { logger } from '../utils';
export class PrepareFlutterService extends PrepareToolBaseService {
readonly name = 'flutter';

constructor(@inject(EnvService) private readonly envSvc: EnvService) {
super();
}

override async execute(): Promise<void> {
const flutter = join(this.envSvc.userHome, '.flutter');
await fs.writeFile(flutter, '{ "firstRun": false, "enabled": false }');
Expand Down

0 comments on commit 1c6f0aa

Please sign in to comment.