Skip to content

Commit

Permalink
chore: Add twilio docs link for twilio update (twilio#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
onuzbee authored Jan 24, 2022
1 parent 8907905 commit 8c36f69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/hooks/prerun/install-prerun.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
/* eslint-disable no-console */
const chalk = require('chalk');

const UPDATE_ALERT = `Warning: Use '${chalk.bold('npm update twilio-cli')}' for npm based installations. `;
const urlUtil = require('../../services/hyperlink-utility');

const TWILIO_CLI_DOCS_LINK = 'https://twil.io/cli';
let UPDATE_ALERT = '';

module.exports = async function pluginPostRun(options) {
if (options.Command.id === 'update') {
const hyperLink = urlUtil.convertToHyperlink('MORE INFO', TWILIO_CLI_DOCS_LINK);
if (hyperLink.isSupported) {
UPDATE_ALERT = UPDATE_ALERT.concat(hyperLink.url);
} else {
UPDATE_ALERT = UPDATE_ALERT.concat(`MORE INFO: ${TWILIO_CLI_DOCS_LINK}`);
}
console.warn(chalk.greenBright(` » ${UPDATE_ALERT}`));
}
};
4 changes: 2 additions & 2 deletions test/hooks/prerun/install-prerun.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ describe('hooks', () => {

test.it('no warning when other commands are run', () => {
pluginFunc(pluginAvailable);
expect(console.warn.calledWith(sinon.match('npm update'))).to.be.false;
expect(console.warn.calledWith(sinon.match('MORE INFO'))).to.be.false;
});

test.it('warning when update command is run', () => {
pluginFunc(update);
expect(console.warn.calledWith(sinon.match('npm update'))).to.be.true;
expect(console.warn.calledWith(sinon.match('MORE INFO'))).to.be.true;
});
});
});
Expand Down

0 comments on commit 8c36f69

Please sign in to comment.