Skip to content

Commit

Permalink
fix(lint): resolve linting issues, fix typo in service name
Browse files Browse the repository at this point in the history
  • Loading branch information
mcaden committed May 18, 2021
1 parent df30053 commit 60031df
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions apps/generator-cli/src/app/app.module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AppModule} from './app.module';
import {Test} from '@nestjs/testing';
import {PassTroughService, VersionManagerService} from './services';
import {PassThroughService, VersionManagerService} from './services';
import {of} from 'rxjs';
import {COMMANDER_PROGRAM} from './constants';

Expand All @@ -12,7 +12,7 @@ describe('AppModule', () => {
parse: jest.fn(),
}

const passTroughServiceMock = {
const passThroughServiceMock = {
init: jest.fn(),
}

Expand All @@ -27,22 +27,22 @@ describe('AppModule', () => {

[
...Object.values(versionManagerServiceMock),
...Object.values(passTroughServiceMock),
...Object.values(passThroughServiceMock),
...Object.values(programMock),
].forEach(spy => spy.mockReset())

const moduleRef = await Test.createTestingModule({
providers: [
{provide: COMMANDER_PROGRAM, useValue: programMock},
{provide: VersionManagerService, useValue: versionManagerServiceMock},
{provide: PassTroughService, useValue: passTroughServiceMock},
{provide: PassThroughService, useValue: passThroughServiceMock},
]
}).compile();

fixture = new AppModule(
moduleRef.get(COMMANDER_PROGRAM),
moduleRef.get(VersionManagerService),
moduleRef.get(PassTroughService),
moduleRef.get(PassThroughService),
)
})

Expand All @@ -55,7 +55,7 @@ describe('AppModule', () => {
process.argv = ['foo', 'baz']

programMock.parse.mockImplementation(() => {
expect(passTroughServiceMock.init).toBeCalledTimes(1)
expect(passThroughServiceMock.init).toBeCalledTimes(1)
expect(versionManagerServiceMock.downloadIfNeeded).toBeCalledTimes(1)
})
})
Expand Down
8 changes: 4 additions & 4 deletions apps/generator-cli/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as url from 'url';

import { COMMANDER_PROGRAM, LOGGER } from './constants';
import { VersionManagerController } from './controllers/version-manager.controller';
import { ConfigService, GeneratorService, PassTroughService, UIService, VersionManagerService } from './services';
import { ConfigService, GeneratorService, PassThroughService, UIService, VersionManagerService } from './services';

let proxyConfig: AxiosProxyConfig;
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
Expand All @@ -31,7 +31,7 @@ if (proxyUrl) {
UIService,
ConfigService,
GeneratorService,
PassTroughService,
PassThroughService,
VersionManagerService,
{
provide: COMMANDER_PROGRAM,
Expand All @@ -45,7 +45,7 @@ export class AppModule implements OnApplicationBootstrap {
constructor(
@Inject(COMMANDER_PROGRAM) private readonly program: Command,
private readonly versionManager: VersionManagerService,
private readonly passTroughService: PassTroughService
private readonly passThroughService: PassThroughService
) {
}

Expand All @@ -60,7 +60,7 @@ export class AppModule implements OnApplicationBootstrap {
}

await this.versionManager.downloadIfNeeded(selectedVersion);
await this.passTroughService.init();
await this.passThroughService.init();
this.program.parse(process.argv);

};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class PassthroughCommandMock {
name = jest.fn().mockReturnValue(this._name);
options: any = {};
options: { [key: string]: string } = {};

parseOptions = jest.fn().mockImplementation(() => {
const result = this.args.find(a => a.startsWith('--custom-generator'))?.split('=')[1];
Expand Down
2 changes: 1 addition & 1 deletion apps/generator-cli/src/app/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './ui.service'
export * from './config.service'
export * from './generator.service'
export * from './pass-trough.service'
export * from './pass-through.service'
export * from './version-manager.service'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Test} from '@nestjs/testing';
import {PassTroughService} from './pass-trough.service';
import {PassThroughService} from './pass-through.service';
import {mocked} from 'ts-jest/utils';
import {COMMANDER_PROGRAM, LOGGER} from '../constants';
import {VersionManagerService} from './version-manager.service';
Expand All @@ -12,9 +12,9 @@ jest.mock('child_process');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const childProcess = mocked(require('child_process'), true)

describe('PassTroughService', () => {
describe('PassThroughService', () => {

let fixture: PassTroughService;
let fixture: PassThroughService;
let commandMock: CommandMock;

const log = jest.fn()
Expand All @@ -27,15 +27,15 @@ describe('PassTroughService', () => {

const moduleRef = await Test.createTestingModule({
providers: [
PassTroughService,
PassThroughService,
{provide: VersionManagerService, useValue: {filePath, getSelectedVersion}},
{provide: GeneratorService, useValue: {generate, enabled: true}},
{provide: COMMANDER_PROGRAM, useValue: commandMock},
{provide: LOGGER, useValue: {log}},
],
}).compile();

fixture = moduleRef.get(PassTroughService);
fixture = moduleRef.get(PassThroughService);
});

describe('API', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { exec, spawn } from 'child_process';
import { GeneratorService } from './generator.service';

@Injectable()
export class PassTroughService {
export class PassThroughService {

constructor(
@Inject(LOGGER) private readonly logger: LOGGER,
Expand Down Expand Up @@ -45,13 +45,13 @@ export class PassTroughService {
}
}

this.passTrough([cmd.name(), ...args], cmd.opts().customGenerator);
this.passThrough([cmd.name(), ...args], cmd.opts().customGenerator);
});
});

}

public passTrough = (args: string[] = [], customGenerator: string) =>
public passThrough = (args: string[] = [], customGenerator: string) =>
spawn(this.cmd(customGenerator), args, {
stdio: 'inherit',
shell: true
Expand Down Expand Up @@ -88,7 +88,7 @@ export class PassTroughService {
});
});

private cmd(customJarPath: string = '') {
private cmd(customJarPath = '') {
const cliPath = this.versionManager.filePath();
const cpDelimiter = process.platform === "win32" ? ';' : ':';
const subCmd = customJarPath
Expand Down

0 comments on commit 60031df

Please sign in to comment.