autoinstallers/install/secu/make/node_modules/cmd-promise/test/my-npm-version.js
2022-05-31 18:28:17 -05:00

26 lines
594 B
JavaScript

const semver = require('semver')
const cmd = require('../cmd-promise')
console.log('cmd-promise: More involved example.')
const commands = `
npm view npm version
npm -v
`
cmd(commands).then(out => {
return {
npm: out[0].stdout.replace(/\n/g, ''),
me: out[1].stdout.replace(/\n/g, '')
}
}).then(versions => {
if (semver.lt(versions.me, versions.npm)) {
console.log(`My npm version is out of date (npm install npm@latest -g).`)
} else {
console.log(`My npm version is up to date! :-)`)
}
}).catch(err => {
console.log('err =', err)
})