Skip to content

Commit

Permalink
Print github-specific deprecation notice on GH.
Browse files Browse the repository at this point in the history
  • Loading branch information
tasdomas committed Oct 14, 2022
1 parent e17483d commit 8429194
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bin/legacy/deprecation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
const winston = require('winston');

// deprecationNotice adds middleware to the yargs chain to display a deprecation notice.
const deprecationNotice = (opts = {}) => {
// addDeprecationNotice adds middleware to the yargs chain to display a deprecation notice.
const addDeprecationNotice = (opts = {}) => {
const { builder, notice } = opts;
return (yargs) => builder(yargs).middleware([(argv) => winston.warn(notice)]);
return (yargs) =>
builder(yargs).middleware([(opts) => deprecationNotice(opts, notice)]);
};

exports.deprecationNotice = deprecationNotice;
const deprecationNotice = (opts, notice) => {
const { cml } = opts;
if (cml.driver.warn) {
cml.driver.warn(notice);
} else {
winston.warn(notice);
}
};

exports.addDeprecationNotice = addDeprecationNotice;
4 changes: 4 additions & 0 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ class Github {
return command;
}

warn(message) {
console.log(`::warning::${message}`);
}

get sha() {
if (GITHUB_EVENT_NAME === 'pull_request')
return github.context.payload.pull_request.head.sha;
Expand Down

0 comments on commit 8429194

Please sign in to comment.