summaryrefslogtreecommitdiff
path: root/deps/npm/lib/publish.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/publish.js')
-rw-r--r--deps/npm/lib/publish.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/deps/npm/lib/publish.js b/deps/npm/lib/publish.js
index 5d99bfd089..bf60e1d5a6 100644
--- a/deps/npm/lib/publish.js
+++ b/deps/npm/lib/publish.js
@@ -21,6 +21,7 @@ const readJson = BB.promisify(require('read-package-json'))
const semver = require('semver')
const statAsync = BB.promisify(require('graceful-fs').stat)
const writeStreamAtomic = require('fs-write-stream-atomic')
+const readUserInfo = require('./utils/read-user-info.js')
publish.usage = 'npm publish [<tarball>|<folder>] [--tag <tag>] [--access <public|restricted>]' +
"\n\nPublishes '.' if no argument supplied" +
@@ -199,5 +200,13 @@ function upload (arg, pkg, isRetry, cached) {
throw err
}
})
+ }).catch((err) => {
+ if (err.code !== 'EOTP' && !(err.code === 'E401' && /one-time pass/.test(err.message))) throw err
+ // we prompt on stdout and read answers from stdin, so they need to be ttys.
+ if (!process.stdin.isTTY || !process.stdout.isTTY) throw err
+ return readUserInfo.otp('Enter OTP: ').then((otp) => {
+ npm.config.set('otp', otp)
+ return upload(arg, pkg, isRetry, cached)
+ })
})
}