Skip to content

Commit

Permalink
setup commands
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuss committed May 20, 2024
1 parent 5e2e2e4 commit 9fe5958
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ type Hooks = {
[key: string]: () => Promise<void>;
};

type CommandOptions = { [key: string]: { usage: string; type: string } };

type Commands = {
[key: string]:
| Commands
| {
usage: string;
lifecycleEvents: string[];
options?: CommandOptions;
};
};

class ServerlessMake {
log: Log;

Expand All @@ -118,6 +130,7 @@ class ServerlessMake {
pluginConfig: PluginConfig;

hooks?: Hooks;
commands?: Commands;

constructor(serverless: Serverless, protected options: Options) {
this.serverless = serverless;
Expand All @@ -129,7 +142,28 @@ class ServerlessMake {

this.log = new Log(options);

// const commandOptions = {
// // "skip-hooks": {
// // usage: "Skip invocation of all lifecycle hooks",
// // type: "boolean",
// // },
// };

this.hooks = this.setupHooks();
this.commands = {
[`${PLUGIN_NAME}`]: {
commands: {
make: {
lifecycleEvents: ["making", "made"],
// options: commandOptions,
usage: "Runs the specified target in the Makefile.",
},
},
lifecycleEvents: ["make"],
// options: commandOptions,
usage: "Runs make commands",
},
};
}

get environment(): { [key: string]: string | undefined } {
Expand Down Expand Up @@ -219,6 +253,11 @@ class ServerlessMake {
};

build = async (watch?: boolean): Promise<void> => {
console.log(
"!!! hooks",
Object.keys(this.serverless.pluginManager.hooks || {}).join(", ")
);

const { makefile } = await this.make(this.target);

if (watch) {
Expand Down

0 comments on commit 9fe5958

Please sign in to comment.