From e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Mon, 16 Nov 2020 00:10:28 +0100 Subject: api, login, auth --- node_modules/in-publish/index.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 node_modules/in-publish/index.js (limited to 'node_modules/in-publish/index.js') diff --git a/node_modules/in-publish/index.js b/node_modules/in-publish/index.js new file mode 100644 index 0000000..8cfc92f --- /dev/null +++ b/node_modules/in-publish/index.js @@ -0,0 +1,32 @@ +'use strict' +function inCommand (cmd, cmdStr) { + if (process.env.npm_command) { + return process.env.npm_command === cmdStr + } + + try { + var npm_config_argv = JSON.parse(process.env['npm_config_argv']) + } catch (e) { + return false + } + + if (typeof npm_config_argv !== 'object') process.exit(1) + if (!npm_config_argv.cooked) process.exit(1) + if (!npm_config_argv.cooked instanceof Array) process.exit(1) + + var V + while ((V = npm_config_argv.cooked.shift()) !== undefined) { + if (/^-/.test(V)) continue + if (cmd.test(V)) return true + return false + } + return false +} + +exports.inPublish = function () { + return inCommand(/^pu(b(l(i(sh?)?)?)?)?$/, 'publish') +} + +exports.inInstall = function () { + return inCommand(/^i(n(s(t(a(ll?)?)?)?)?)?$/, 'install') +} -- cgit v1.2.3