Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ module.exports = function( Release ) {
return tags;
},

_publishNpm: function() {
// Ask for a one-time password for 2FA-enabled accounts;
// returns OTP as string if provided, undefined otherwise.
_getNpmOtp: async function() {
var otp = await Release.promptFor(
"Enter one-time password if you have 2FA enabled and press Enter.\n" +
"Otherwise, just press Enter." );

return otp || undefined;
},

_publishNpm: async function() {
if ( !Release.npmPublish ) {
return;
}
Expand All @@ -71,16 +81,19 @@ module.exports = function( Release ) {

var npmPublish,
newVersion = Release.readPackage().name + "@" + Release.newVersion,
safety = Release.isTest ? " --dry-run" : "",
npmTags = Release.npmTags();
safety = Release.isTest ? "--dry-run" : "",
npmTags = Release.npmTags(),
otp = await Release._getNpmOtp();

if ( Release.isTest ) {
console.log( "Actual release would now publish to npm using:" );
} else {
console.log( "Publishing to npm, running:" );
}

npmPublish = "npm publish" + safety + " --tag " + npmTags.pop();
npmPublish = `npm publish ${ safety } ${
otp ? `--otp ${ otp }` : ""
} --tag ${ npmTags.pop() }`;
console.log( " " + chalk.cyan( npmPublish ) );
Release.exec( npmPublish );

Expand Down
14 changes: 13 additions & 1 deletion lib/prompt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

var chalk = require( "chalk" );
var chalk = require( "chalk" ),
{ prompt } = require( "enquirer" );

module.exports = function( Release ) {

Expand All @@ -13,6 +14,17 @@ Release.define( {
process.stdin.resume();
},

// prints a given message, provide back the entered string after trimming.
// Also, returns a promise resolving to that string.
promptFor: async function( message ) {
var { input } = await prompt( {
type: "input",
name: "input",
message
} );
return input;
},

confirm: function( fn ) {
console.log( chalk.yellow( "Press enter to continue, or ctrl+c to cancel." ) );
Release.prompt( fn );
Expand Down
21 changes: 21 additions & 0 deletions node_modules/ansi-colors/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

279 changes: 279 additions & 0 deletions node_modules/ansi-colors/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading