How to use update-notifier - 10 common examples

To help you get started, we’ve selected a few update-notifier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maticzav / emma-cli / packages / create-emma / src / bin.tsx View on Github external
/* Spec */

const cli = meow(
  mls`
  | Usage
  |  $ create-emma <dir>
  `,
)

/**
 * Make sure that user is on the latest version
 * avaiable in case they have connection to NPM.
 */

const notifier = updateNotifier(cli)

notifier.notify()

if (notifier.update) {
  process.exit(0)
}

/* Main */

// function breakStep() {
//   console.log(`-------------------------------------------------------`)
// }

export async function main(cwd: string) {
  console.log(
    drawBox({</dir>
github alfg / srv / bin / srv.js View on Github external
#!/usr/bin/env node

/* eslint no-console:0 import/no-unresolved:0 */

import dotenv from 'dotenv';
import program from 'commander';
import chalk from 'chalk';
import updateNotifier from 'update-notifier';
import pkg from '../package.json';
import config from './default.json';
import { resolve } from 'path';

import * as cmd from './cmd/index';

updateNotifier({ pkg }).notify();

// Banner.
const banner = `
▼ ${pkg.name} - v${pkg.version}
${pkg.homepage}
`;
console.log(chalk.cyan(banner));

// Load dotenv.
dotenv.config({ silent: true });

// Parse CLI args.
program
  .version(pkg.version)
  .usage('entrypoint.js [options]')
  .option('-p, --port [n]', 'Port to listen on', process.env.PORT)
github huan / matrix-appservice-wechaty / src / cli / check-update.ts View on Github external
.then(pack => {
      if (!pack) {
        throw new Error('package.json not found')
      }

      const pkg = pack.package
      // 1 week
      const updateCheckInterval = 1000 * 60 * 60 * 24 * 7

      const notifier  = new UpdateNotifier({
        pkg,
        updateCheckInterval,
      })
      notifier.notify()
      return null
    })
    .catch(console.error)
github maticzav / emma-cli / src / index.js View on Github external
#!/usr/bin/env node

import meow from 'meow'
import { h, render } from 'ink'
import updateNotifier from 'update-notifier'

import emma from './emma'

// Notify updater
const pkg = require(`../package.json`)

updateNotifier({ pkg }).notify()

// CLI

const cli = meow(`
   Usage
     $ emma

   Example
     $ emma -D

   Options
     --dev -D      Add to dev dependencies.

   Run without package-name to enter live search.
   Use keyboard to search through package library.
   Use up/down to select packages.
github dsebastien / modernWebDevGenerator / app / index.es2015.js View on Github external
const checkForUpdates = () =>{
				const notifier = updateNotifier({
								pkg: packageJSON
								//,updateCheckInterval: 1 // useful for debugging
				});

				let message = [];

				let retVal;

				if(notifier.update){
								message.push("Update available: " + chalk.green.bold(notifier.update.latest) + chalk.gray(" (current: " + notifier.update.current + ")"));
								message.push("Run " + chalk.magenta("npm install -g " + packageJSON.name) + " to update.");
								retVal = yosay(message.join(" "), {maxLength: stringLength(message[ 0 ])});
				}
				return retVal;
};
github egoist / bili / src / index.js View on Github external
/* eslint-disable unicorn/no-process-exit */
import cac from 'cac'
import update from 'update-notifier'
import bili from './bili'
import { handleRollupError } from './utils'

const cli = cac()

update({ pkg: cli.pkg }).notify()

cli
  .option('config', {
    desc: 'Path to config file',
    alias: 'c'
  })
  .option('watch', {
    desc: 'Run in watch mode',
    alias: 'w'
  })
  .option('filename', {
    desc: 'The filename of output file, no extension',
    alias: 'n'
  })
  .option('out-dir', {
    desc: 'The output directory',
github arnoldczhang / fe-guide / src / node / skeleton / bin / index.js View on Github external
} = require('fs');
const chokidar = require('chokidar');

const run = require('../dist/index.cjs');
const cfg = require('../package.json');
const options = {
  root: process.cwd(),
};
const thisDir = process.cwd();
const {
  defaultConfigName,
} = run;


// 更新检查方法
const notifier = new UpdateNotifier({
  pkg: cfg,
  callback(err, result) {
    if (err) return;
    if (semCmp(result.latest, result.current) > 0) {
      const message =
        'Update available ' +
        color.dim(result.current) +
        color.reset(' → ') +
        color.green(result.latest) +
        ' \nRun ' +
        color.cyan('npm i -g ' + json.name) +
        ' to update';
      const msg =
        '\n' +
        boxen(message, {
          padding: 1,
github viewstools / morph / cli.js View on Github external
input = path.normalize(path.join(process.cwd(), input))
  }

  try {
    if ((await fs.stat(path.join(input, 'src'))).isDirectory()) {
      input = path.join(input, 'src')
    }
  } catch (error) {}

  if (clean) {
    console.log(`Cleaning up ${input}...`)
    await cleanup(input, verbose)
    process.exit()
  }

  updateNotifier({ pkg }).notify()

  if (verbose) {
    console.log(chalk.underline(`Views Tools morpher v${pkg.version}`))

    console.log(
      `\nWill morph files at "${chalk.green(input)}" as "${chalk.green(as)}" ${
        tools ? 'with Views Tools' : 'without Views Tools'
      }`
    )

    if (shouldWatch && !tools) {
      console.log(
        chalk.bgRed('                                               ')
      )
      console.log()
      console.log(`🚨 You're missing out!!!`)
github callumlocke / esbox / src / lib / cli.js View on Github external
import cc from 'cli-color';
import execa from 'execa';
import minimist from 'minimist';
import path from 'path';
import pathExists from 'path-exists';
import pkg from '../../package.json';
import updateNotifier from 'update-notifier';
import { clearScreen } from 'ansi-escapes';
import { debounce } from 'lodash';
import { tick, cross } from 'figures';

const isMac = /^darwin/.test(process.platform);

process.title = 'esbox';

updateNotifier({ pkg }).notify();

const red = cc.red;
const black = cc.black;
const bgWhite = cc.xtermSupported ? cc.bgXterm(250) : cc.bgWhite;
const brown = cc.xtermSupported ? cc.xterm(137) : cc.yellow;
const grey = cc.xtermSupported ? cc.xterm(241) : cc.blackBright;

const help = `
  ${bgWhite('                       ')}
  ${bgWhite(`  ${isMac ? '📦' : ''}  ${black('ES2016 in a box')}   `)}
  ${bgWhite(`     ${grey('git.io/esbox')}      `)}
  ${bgWhite('                       ')}

  ${brown('Usage')}
    ${grey('>')} esbox ${grey('FILENAME')}
github jackfranklin / doccy / bin / cli.js View on Github external
#!/usr/bin/env node
var doccy = require("../doccy.js");
var program = require("commander");
var pjson = require('../package.json');
var glob = require("glob");
var mkdirp = require("mkdirp");
var notifier = require('update-notifier');

if (notifier.update) {
    notifier.notify('Update available: ' + notifier.update.latest);
}

program.version(pjson.version)
  .option('-g, --glob [fileGlob]', 'Run Doccy on all files matching [fileGlob]')
  .option('-o, --output [outputDir]', 'Specify the directory to output documentation to', 'docs')
  .parse(process.argv);

if(program.glob) {
  glob(program.glob, {}, function(err, files) {
    if(files.length) mkdirp(program.output);
    files.forEach(function(file) {
      if(file.indexOf("node_modules") == -1) {
        doccy.init(file, program.output);
      }
    });
  });

update-notifier

Update notifications for your CLI app

BSD-2-Clause
Latest version published 4 months ago

Package Health Score

79 / 100
Full package analysis