update-notifier with custom scope registry
No new concept, use update-notifier under the hood.
npm i @hspkg/update-notifier -S
const chalk = require('chalk')
const updateNotifier = require('@hspkg/update-notifier')
const pkg = require('./package.json')
const notifier = updateNotifier({
// optional, default is package scope
scope: '@ali',
// optional, default is https://registry.npmjs.org
registry: 'https://registry.npm.taobao.org',
})({ pkg })
// optional, the same as update-notifier
notifier.update && notifier.notify({
message: `发现新版本 ${chalk.gray(notifier.update.current)} -> ${chalk.green(notifier.update.latest)}
运行 ${chalk.cyan('cnpm i -g ') notifier.packageName} 更新`
})
// Put your code here
The tool writes custom registry into $HOME/.config/npm
whose priority is lower than $HOME/.npmrc
, so users can override the custom registry in $HOME/.npmrc
.
MIT © Cody Chan