Skip to content

Commit 25b452d

Browse files
authored
feat: suggest gh pr commands to finish landing (#583)
Also make the output easier to copy and paste.
1 parent c515276 commit 25b452d

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

lib/landing_session.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const {
1111
runAsync, runSync, forceRunAsync
1212
} = require('./run');
1313
const Session = require('./session');
14-
const { shortSha } = require('./utils');
14+
const { shortSha, isGhAvailable } = require('./utils');
1515

1616
const isWindows = process.platform === 'win32';
1717

@@ -416,11 +416,16 @@ class LandingSession extends Session {
416416
}
417417

418418
this.cleanFiles();
419-
cli.log('Temporary files removed');
419+
cli.log('Temporary files removed.');
420420
cli.log('To finish landing:');
421-
cli.log(`1. Run \`git push ${upstream} ${branch}\``);
421+
cli.log('1. Run: ');
422+
cli.log(` git push ${upstream} ${branch}`);
422423
const url = `https://github.com/${owner}/${repo}/pull/${prid}`;
423424
cli.log(`2. Post "Landed in ${willBeLanded}" in ${url}`);
425+
if (isGhAvailable()) {
426+
cli.log(` gh pr comment ${prid} --body "Landed in ${willBeLanded}"`);
427+
cli.log(` gh pr close ${prid}`);
428+
}
424429
}
425430

426431
async continue() {

lib/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const which = require('which');
4+
35
exports.ascending = function(a, b) {
46
if (a === b) return 0;
57
return a < b ? -1 : 1;
@@ -26,3 +28,11 @@ exports.flatten = flatten;
2628
exports.shortSha = function shortSha(sha) {
2729
return sha.slice(0, 12);
2830
};
31+
32+
let isGhAvailableCache;
33+
exports.isGhAvailable = function isGhAvailable() {
34+
if (isGhAvailableCache === undefined) {
35+
isGhAvailableCache = which.sync('gh', { nothrow: true }) !== null;
36+
}
37+
return isGhAvailableCache;
38+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"proxy-agent": "^5.0.0",
5252
"replace-in-file": "^6.2.0",
5353
"rimraf": "^3.0.2",
54+
"which": "^2.0.2",
5455
"yargs": "^16.2.0"
5556
},
5657
"devDependencies": {

0 commit comments

Comments
 (0)