1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/in-publish/index.js

33 lines
780 B
JavaScript
Raw Permalink Normal View History

2023-12-18 13:12:25 +08:00
'use strict'
2023-12-28 23:41:32 +08:00
function inCommand (cmd, cmdStr) {
if (process.env.npm_command) {
return process.env.npm_command === cmdStr
}
2023-12-18 13:12:25 +08:00
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 () {
2023-12-28 23:41:32 +08:00
return inCommand(/^pu(b(l(i(sh?)?)?)?)?$/, 'publish')
2023-12-18 13:12:25 +08:00
}
exports.inInstall = function () {
2023-12-28 23:41:32 +08:00
return inCommand(/^i(n(s(t(a(ll?)?)?)?)?)?$/, 'install')
2023-12-18 13:12:25 +08:00
}