Skip to content

Instantly share code, notes, and snippets.

@cdupuis
Last active October 24, 2019 17:26
Show Gist options
  • Save cdupuis/9fa39de0a8795d3a229028ffee67e6ed to your computer and use it in GitHub Desktop.
Save cdupuis/9fa39de0a8795d3a229028ffee67e6ed to your computer and use it in GitHub Desktop.
import {
goal,
hasFile,
PlannedGoal,
SdmGoalState,
} from "@atomist/sdm";
import { configure } from "@atomist/sdm-core";
/**
* Atomist SDM Sample
* @description SDM demonstrate dynamic goals
* @tag sdm,generator,dotnet-core
*/
export const configuration = configure(async sdm => {
const messageGoal = goal({ displayName: "Message" }, async gi => {
await gi.addressChannels(`Hello ${gi.parameters.count}`);
});
messageGoal.plan = async ci => {
const countFile = await ci.project.getFile("count");
const counter: number = +(await countFile.getContent()).trim();
const goals: PlannedGoal[] = [];
for (let i = 0; i < counter; i++) {
goals.push({
details: {
displayName: `Message #${i}`,
},
parameters: {
count: i,
},
});
}
return {
count: {
goals,
},
};
};
return {
plan: {
test: hasFile("count"),
goals: messageGoal,
},
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment