Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
build without step commits
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Jun 25, 2020
commit efd3c0b3490407557ce3860f7de1ce579cdc2684
13 changes: 8 additions & 5 deletions src/utils/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export function parse(params: ParseParams): any {
// add level step commits
const { steps, ...configLevelProps } = configLevel;
level = { ...configLevelProps, ...level };

if (steps) {
steps.forEach((step: T.Step, index: number) => {
try {
Expand All @@ -151,12 +152,14 @@ export function parse(params: ParseParams): any {
};

const stepSetupKey = `${step.id}:T`;

if (!step?.setup) {
step.setup = {};
}
if (!step.setup.commits) {
step.setup.commits = [];
}
if (params.commits[stepSetupKey]) {
if (!step.setup) {
step.setup = {
commits: [],
};
}
step.setup.commits = params.commits[stepSetupKey];
}

Expand Down
49 changes: 49 additions & 0 deletions tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,55 @@ The first step
};
expect(result.levels).toEqual(expected.levels);
});
it("should load no commits if none found for a step", () => {
const md = `# Title

Description.

## 1. Title

First line

### 1.1

The first step
`;
const skeleton = {
levels: [
{
id: "1",
steps: [{ id: "1" }],
},
],
};
const result = parse({
text: md,
skeleton,
commits: {},
});
const expected = {
summary: {
description: "Description.",
},
levels: [
{
id: "1",
summary: "First line",
content: "First line",
steps: [
{
id: "1.1",
content: "The first step",
setup: {
commits: [],
},
},
],
},
],
};
expect(result.levels[0].steps[0]).toEqual(expected.levels[0].steps[0]);
});
});

describe("config", () => {
Expand Down