Skip to content

feat: add 'replace_output' props to plugin, allowing plugins to modif… #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 packages/engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/engine",
"version": "0.1.6-beta.3",
"version": "0.1.6-beta.5",
"description": "a engine lib for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion packages/engine/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IAction, IActionLevel, IActionType, IAllowFailure, IComponentAction, IHookType, IPluginAction, IRunAction, getInputs } from '@serverless-devs/parse-spec';
import { isEmpty, filter, includes, set, get } from 'lodash';
import { isEmpty, filter, includes, set, get, cloneDeep } from 'lodash';
import * as utils from '@serverless-devs/utils';
import { DevsError, ETrackerType } from '@serverless-devs/utils';
import fs from 'fs-extra';
Expand Down Expand Up @@ -248,6 +248,10 @@ You can still use them now, but we suggest to modify them.`)
const inputs = isEmpty(this.record.pluginOutput) ? this.inputs : this.record.pluginOutput;
// Execute the plugin with the determined inputs and provided arguments.
this.record.pluginOutput = await instance(inputs, hook.args, this.logger);
// If prop 'replace_output' is true, replace the record's step output with the plugin output.
if (hook.replace_output) {
this.record.step.output = cloneDeep(this.record.pluginOutput);
}
} catch (e) {
const error = e as Error;
// Check if the failure is allowed based on the record's allowFailure setting.
Expand Down
2 changes: 1 addition & 1 deletion packages/parse-spec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/parse-spec",
"version": "0.0.29",
"version": "0.0.30-beta.1",
"description": "a parse yaml spec lib for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/parse-spec/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface IPluginAction {
level: `${IActionLevel}`;
projectName: string;
allow_failure?: boolean | IAllowFailure;
replace_output?: boolean;
}
export interface IComponentAction {
hookType: `${IHookType}`;
Expand Down
Loading