Skip to content

Commit 80eb18f

Browse files
authored
Merge pull request #166 from RobertReaves/rework-scripts
Fixed scripts running at incorrect times during workflow
2 parents 1ca4d11 + 8e59470 commit 80eb18f

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ The following will create `pre` and `post` script hooks for the `start` command
316316

317317
```
318318
"tag-release": {
319-
"preStart": node ./preStart.js,
320-
"postStart": node ./postStart.js
319+
"prestart": "node ./preStart.js",
320+
"poststart": "node ./postStart.js"
321321
}
322322
```
323323

324-
As you can see from the example your script name will need to be `pre` followed by the `tag-release` command capitalized. For example, if I wanted to hook into the `dev` command
325-
my script names would be `preDev` and `postDev`.
324+
As you can see from the example your script name will need to be `pre` followed by the `tag-release` command. For example, if I wanted to hook into the `dev` command
325+
my script names would be `predev` and `postdev`.
326326

327327
Here is a chart of all the commands `tag-release` offers:
328328
```
@@ -335,7 +335,7 @@ qa
335335
reset
336336
```
337337

338-
> **Note**: You will need to use the full name of the command, not just an alias. For instance, you couldn't do `prePro`. Instead, it would be `prePromote`.
338+
> **Note**: You will need to use the full name of the command, not just an alias. For instance, you couldn't do `prepro`. Instead, it would be `prepromote`.
339339
340340

341341
## Release Workflow

bin/tag-release-continue.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const utils = require("../src/utils.js");
88
const filterFlowBasedOnDevelopBranch = require("../src/helpers/filterFlowBasedOnDevelopBranch");
99
const getCurrentBranch = require("../src/helpers/getCurrentBranch");
1010
const runWorkflow = require("../src/helpers/runWorkflow");
11+
const { runPostScript } = require("../src/workflows/steps/index.js");
1112

1213
utils.applyCommanderOptions(commander);
1314

@@ -24,11 +25,21 @@ const callback = async options => {
2425
if (options.branch.includes("promote-release")) {
2526
flow = filterFlowBasedOnDevelopBranch(options, promoteContinue);
2627

28+
options.scripts = utils.getScripts("promote");
29+
options.command = "promote";
30+
if (options.scripts.postpromote) {
31+
flow.push(runPostScript);
32+
}
2733
return runWorkflow(flow, options);
2834
}
2935

3036
flow = filterFlowBasedOnDevelopBranch(options, prContinue);
3137

38+
options.scripts = utils.getScripts("pr");
39+
options.command = "pr";
40+
if (options.scripts.postpr) {
41+
flow.push(runPostScript);
42+
}
3243
return runWorkflow(flow, options);
3344
};
3445

bin/tag-release-pr.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
const utils = require("../src/utils.js");
1111
const filterFlowBasedOnDevelopBranch = require("../src/helpers/filterFlowBasedOnDevelopBranch");
1212
const runWorkflow = require("../src/helpers/runWorkflow");
13+
const { runPostScript } = require("../src/workflows/steps/index.js");
1314

1415
utils.applyCommanderOptions(commander);
1516

@@ -23,11 +24,17 @@ const callback = options => {
2324
if (options.conflict) {
2425
flow = filterFlowBasedOnDevelopBranch(options, prRebaseConflict);
2526

27+
if (options.scripts[`post${options.command}`]) {
28+
flow.push(runPostScript);
29+
}
2630
return runWorkflow(flow, options);
2731
}
2832

2933
flow = filterFlowBasedOnDevelopBranch(options, prRebaseSuccess);
3034

35+
if (options.scripts[`post${options.command}`]) {
36+
flow.push(runPostScript);
37+
}
3138
return runWorkflow(flow, options);
3239
};
3340

bin/tag-release-qa.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
const utils = require("../src/utils.js");
1010
const filterFlowBasedOnDevelopBranch = require("../src/helpers/filterFlowBasedOnDevelopBranch");
1111
const runWorkflow = require("../src/helpers/runWorkflow");
12+
const { runPostScript } = require("../src/workflows/steps/index.js");
1213

1314
utils.applyCommanderOptions(commander);
1415

@@ -23,11 +24,17 @@ const callback = options => {
2324
if (options.packages.length && onFeatureBranch) {
2425
flow = filterFlowBasedOnDevelopBranch(options, qaUpdate);
2526

27+
if (options.scripts[`post${options.command}`]) {
28+
flow.push(runPostScript);
29+
}
2630
return runWorkflow(flow, options);
2731
}
2832

2933
flow = filterFlowBasedOnDevelopBranch(options, qaDefault);
3034

35+
if (options.scripts[`post${options.command}`]) {
36+
flow.push(runPostScript);
37+
}
3138
return runWorkflow(flow, options);
3239
};
3340

src/helpers/setup.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ const filterFlowBasedOnDevelopBranch = require("./filterFlowBasedOnDevelopBranch
88
const utils = require("../utils");
99

1010
const setup = async options => {
11-
if (!options.callback) {
12-
/* istanbul ignore next */
13-
options.callback = () => console.log("Finished"); // eslint-disable-line no-console
14-
}
1511
options.configPath = options.config || "./package.json";
1612
options.version = await utils.getCurrentVersion();
1713

@@ -25,12 +21,23 @@ const setup = async options => {
2521
options.workflow
2622
);
2723

28-
options.scripts = await utils.getScripts(options.command);
29-
if (options.scripts[`pre${options.command}`]) {
24+
options.scripts = utils.getScripts(options.command);
25+
if (
26+
options.command !== "continue" &&
27+
options.scripts[`pre${options.command}`]
28+
) {
3029
options.workflow.unshift(runPreScript);
3130
}
32-
if (options.scripts[`post${options.command}`]) {
33-
options.workflow.push(runPostScript);
31+
32+
if (!options.callback) {
33+
/* istanbul ignore next */
34+
options.callback = () => console.log("Finished"); // eslint-disable-line no-console
35+
if (
36+
options.command !== "continue" &&
37+
options.scripts[`post${options.command}`]
38+
) {
39+
options.workflow.push(runPostScript);
40+
}
3441
}
3542

3643
if (!utils.fileExists(options.configPath) && options.command !== "l10n") {

0 commit comments

Comments
 (0)