Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = {
// A set of global variables that need to be available in all test environments
globals: {
"ts-jest": {
"tsConfigFile": "tsconfig.tests.json"
"tsConfig": "tsconfig.tests.json"
}
},

Expand Down
63 changes: 13 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"ts-jest": "^24.0.2",
"ts-loader": "^6.0.4",
"ts-node": "^8.3.0",
"tslint": "^5.11.0",
"tslint": "^5.18.0",
"typescript": "^3.0.3"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ function getParams(
}

function instantiateCommand(command: CommandDefinition<any>) {
const constructor = command.type as { new(...args: any[]): Command<any> };
const constructor = command.type;
const instance = iocContainer ? iocContainer.get(constructor) : new constructor();
return instance;
}

function registerCommandOption(
cliCommand: cli.Command,
paramsClass: { new(...args: any[]): any; },
paramsClass: new (...args: any[]) => any,
option: CommandOptionDefinition
) {
const optionUsage = getOptionUsage(option);
Expand Down
10 changes: 3 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ export interface Command<TParams> {
execute(params: TParams): Promise<void> | void;
}

export interface CommandParamsClass<T> {
new(): T;
}
export type CommandParamsClass<T> = new () => T;

export interface CommandClass<TParams> {
new(...args: any[]): Command<TParams>;
}
export type CommandClass<TParams> = new (...args: any[]) => Command<TParams>;

export interface IocContainer {
get: <T>(Class: { new(...args: any[]): T }) => T;
get: <T>(Class: new (...args: any[]) => T) => T;
}