You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
467 B
18 lines
467 B
'use strict'
|
|
|
|
module.exports = function () {
|
|
if (!process.env.npm_config_user_agent) {
|
|
return undefined
|
|
}
|
|
return pmFromUserAgent(process.env.npm_config_user_agent)
|
|
}
|
|
|
|
function pmFromUserAgent (userAgent) {
|
|
const pmSpec = userAgent.split(' ')[0]
|
|
const separatorPos = pmSpec.lastIndexOf('/')
|
|
const name = pmSpec.substring(0, separatorPos)
|
|
return {
|
|
name: name === 'npminstall' ? 'cnpm' : name,
|
|
version: pmSpec.substring(separatorPos + 1)
|
|
}
|
|
}
|
|
|