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

Commit

Permalink
Merge pull request #10 from atomist/defer-fulfillment
Browse files Browse the repository at this point in the history
Defer adding fulfillment
  • Loading branch information
ddgenome authored Apr 5, 2019
2 parents 61c4dee + e221c89 commit 1c39fcc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
28 changes: 22 additions & 6 deletions lib/publishToS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import {
ExecuteGoalResult,
GoalInvocation,
GoalWithFulfillment,
lastLinesLogInterpreter,
LogSuppressor,
PredicatedGoalDefinition,
ProjectAwareGoalInvocation,
slackWarningMessage,
SoftwareDeliveryMachine,
} from "@atomist/sdm";
import {
SlackMessage,
Expand Down Expand Up @@ -102,16 +103,31 @@ export interface PublishToS3Options {
*/
export class PublishToS3 extends GoalWithFulfillment {

constructor(options: PublishToS3Options & PredicatedGoalDefinition) {
constructor(private readonly options: PublishToS3Options & PredicatedGoalDefinition) {
super({
workingDescription: "Publishing to S3",
completedDescription: "Published to S3",
...options,
});
this.with({
name: "publishToS3",
goalExecutor: executePublishToS3(options),
logInterpreter: lastLinesLogInterpreter("Failed to publish to S3", 10),
}

/**
* Called by the SDM on initialization. This function calls
* `super.register` and adds a startup listener to the SDM. The
* startup listener registers a default goal fulfillment if there
* is none that suppresses logs posted to chat.
*/
public register(sdm: SoftwareDeliveryMachine): void {
super.register(sdm);

sdm.addStartupListener(async () => {
if (this.fulfillments.length === 0 && this.callbacks.length === 0) {
this.with({
name: `publishToS3-${this.options.bucketName}`,
goalExecutor: executePublishToS3(this.options),
logInterpreter: LogSuppressor,
});
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion 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
@@ -1,6 +1,6 @@
{
"name": "@atomist/sdm-pack-s3",
"version": "0.2.1",
"version": "0.3.0",
"description": "SDM extension pack for publishing artifacts to AWS S3",
"author": {
"name": "Atomist",
Expand Down

0 comments on commit 1c39fcc

Please sign in to comment.