18 lines
408 B
JavaScript
18 lines
408 B
JavaScript
'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('/')
|
|
return {
|
|
name: pmSpec.substr(0, separatorPos),
|
|
version: pmSpec.substr(separatorPos + 1)
|
|
}
|
|
}
|