Skip to content

Commit 1fd1cca

Browse files
committed
switch to entrypoint
1 parent d41168a commit 1fd1cca

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/index.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ type Hooks = {
113113
type Commands = {
114114
[key: string]: {
115115
lifecycleEvents?: string[];
116+
type?: string;
116117
};
117118
};
118119

@@ -138,7 +139,8 @@ class ServerlessMake {
138139

139140
this.commands = {
140141
[PLUGIN_NAME]: {
141-
lifecycleEvents: [this.target],
142+
lifecycleEvents: ["made"],
143+
type: "entrypoint",
142144
},
143145
};
144146

@@ -157,14 +159,12 @@ class ServerlessMake {
157159
return this.pluginConfig.target || "";
158160
}
159161

160-
get afterTarget(): string {
161-
return `after:make${this.target ? `:${this.target}` : ""}`;
162-
}
163-
164162
setupHooks = () => {
165163
const hooks: Hooks = {
166164
initialize: async () => {},
167-
[this.afterTarget]: async () => {},
165+
[`${PLUGIN_NAME}:made`]: async () => {
166+
this.log.verbose(`!!! ${PLUGIN_NAME}:made`);
167+
},
168168
"before:offline:start": async () => {
169169
this.log.verbose("before:offline:start");
170170
let errored = false;
@@ -203,7 +203,7 @@ class ServerlessMake {
203203
const pluginHooks = this.pluginConfig.hooks || {};
204204

205205
Object.entries(pluginHooks).forEach(([hook, target]) => {
206-
if (hooks[hook] && hook !== this.afterTarget) {
206+
if (hooks[hook] && hook !== `${PLUGIN_NAME}:made`) {
207207
this.log.warning(
208208
`Unable to override registered internal hook "${hook}"!`
209209
);
@@ -271,11 +271,12 @@ class ServerlessMake {
271271
});
272272
}
273273

274+
const spawn = `${PLUGIN_NAME}:made`;
274275
try {
275-
await this.serverless.pluginManager.spawn(this.afterTarget);
276+
await this.serverless.pluginManager.spawn(`${PLUGIN_NAME}:made`);
276277
} catch (e) {
277278
if (e instanceof Error) {
278-
this.log.warning(`Unable to spawn ${this.afterTarget}`);
279+
this.log.warning(`Unable to spawn ${spawn}`);
279280
}
280281
}
281282
};

0 commit comments

Comments
 (0)