Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Commit

Permalink
fix: format
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Dec 24, 2019
1 parent b1fc539 commit 99edaef
Show file tree
Hide file tree
Showing 17 changed files with 689 additions and 606 deletions.
2 changes: 1 addition & 1 deletion packages/command-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ const core = new CommandHookCore({
core.addPlugin(Plugin); // 载入你的插件
await core.ready(); // 等待初始化
await core.invoke(['command']); // 执行对应的命令
```
```
4 changes: 1 addition & 3 deletions packages/command-core/src/classes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export class CoreError {

}
export class CoreError {}
84 changes: 42 additions & 42 deletions packages/command-core/src/errorMap.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
const ErrorMap = {
commandIsEntrypoint: (info: any) => {
return {
info,
message: `command ${ info.command } is entrypoint, cannot invoke`
};
},
commandNotFound: (info: any) => {
return {
info,
message: `command ${ info.command } not found`
};
},
localPlugin: (info: any) => {
return {
info,
message: `load local plugin '${ info.path }' error '${ info.err.message }'`
};
},
npmPlugin: (info: any) => {
return {
info,
message: `load npm plugin '${ info.path }' error '${ info.err.message }'`
};
},
pluginType: (info: string) => {
return {
info,
message: `only support npm / local / class plugin`
};
}
commandIsEntrypoint: (info: any) => {
return {
info,
message: `command ${info.command} is entrypoint, cannot invoke`,
};
},
commandNotFound: (info: any) => {
return {
info,
message: `command ${info.command} not found`,
};
},
localPlugin: (info: any) => {
return {
info,
message: `load local plugin '${info.path}' error '${info.err.message}'`,
};
},
npmPlugin: (info: any) => {
return {
info,
message: `load npm plugin '${info.path}' error '${info.err.message}'`,
};
},
pluginType: (info: string) => {
return {
info,
message: `only support npm / local / class plugin`,
};
},
};

interface ReturnValue<T> {
info: T;
message: string;
interface ReturnValue<T> {
info: T;
message: string;
}

export default <T>(type: string, info: T): ReturnValue<T> => {
let error = ErrorMap[type];
if (!error) {
return {
info,
message: `error`
}
}
return error(info);
};
let error = ErrorMap[type];
if (!error) {
return {
info,
message: `error`,
};
}
return error(info);
};
Loading

0 comments on commit 99edaef

Please sign in to comment.