@evanpurkhiser/tooling-personal 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cmd/pr.js CHANGED
@@ -84,9 +84,17 @@ async function pr() {
84
84
  const willOpenPr = prs.some(pr => pr.headRefName === branchName);
85
85
  // 03. Rebase and push the selected commits
86
86
  const doRebase = async () => {
87
- await simple_git_1.default()
87
+ const rebase = simple_git_1.default()
88
88
  .env({ ...process.env, GIT_SEQUENCE_EDITOR: `echo "${rebaseContents}" >` })
89
89
  .rebase(['--interactive', '--autostash', 'origin/master']);
90
+ try {
91
+ await rebase;
92
+ }
93
+ catch (error) {
94
+ // Abort a failed rebase
95
+ await simple_git_1.default().rebase(['--abort']);
96
+ throw new Error(`Failed to rebase\n${error}`);
97
+ }
90
98
  };
91
99
  const doPush = async () => {
92
100
  const newCommits = await getCommits();
@@ -107,12 +115,19 @@ async function pr() {
107
115
  // Cork stdout to avoid listr output polluting vim. We'll uncork after we
108
116
  // close vim
109
117
  process.stdout.cork();
110
- const rebaseAndPush = rebaseAndPushTask.run();
111
- const { title, body } = await editor_1.editPullRequest(targetCommit);
112
118
  // 05. Open an editor to write the pull request
119
+ const { editor, editorResult } = await editor_1.editPullRequest(targetCommit);
120
+ const rebaseAndPush = rebaseAndPushTask.run();
121
+ rebaseAndPush.catch(() => editor.kill());
122
+ const { title, body } = await editorResult;
113
123
  // XXX: We cork stdout here to avoid listr from corrupting vims output
114
124
  process.stdout.uncork();
115
- await rebaseAndPush;
125
+ try {
126
+ await rebaseAndPush;
127
+ }
128
+ catch {
129
+ process.exit(1);
130
+ }
116
131
  if (title.length === 0) {
117
132
  console.log(chalk_1.default.red `Missing PR title, aborting`);
118
133
  process.exit(1);
package/dist/editor.js CHANGED
@@ -18,10 +18,13 @@ async function editPullRequest(commit) {
18
18
  shell: true,
19
19
  stdio: 'inherit',
20
20
  });
21
- await new Promise(resolve => editor.on('close', resolve));
22
- const prContents = await promises_1.default.readFile(pullEditFile).then(b => b.toString());
23
- const [title, ...bodyParts] = prContents.split('\n');
24
- const body = bodyParts.join('\n').trim();
25
- return { title, body };
21
+ async function getResult() {
22
+ await new Promise(resolve => editor.on('close', resolve));
23
+ const prContents = await promises_1.default.readFile(pullEditFile).then(b => b.toString());
24
+ const [title, ...bodyParts] = prContents.split('\n');
25
+ const body = bodyParts.join('\n').trim();
26
+ return { title, body };
27
+ }
28
+ return { editor, editorResult: getResult() };
26
29
  }
27
30
  exports.editPullRequest = editPullRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanpurkhiser/tooling-personal",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Evan Purkhiser's personal tooling",
5
5
  "repository": "https://github.com/EvanPurkhiser/tooling-personal",
6
6
  "author": "Evan Purkhiser",