How to use the yargs.argv function in yargs

To help you get started, we’ve selected a few yargs 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 triplecanopy / b-ber / src / tasks / watch.jsx View on Github external
// TODO: which dir is this watching? `book`? `book-epub`?

import path from 'path'
import fs from 'fs-extra'
import nodemon from 'nodemon'
import opn from 'opn'
import yargs from 'yargs'
import { exec } from 'child_process'
import conf from '../modules/config'
import { log } from '../log'

const executor = yargs.argv.$0 === 'bber'
  ? yargs.argv.$0
  : './node_modules/.bin/babel-node ./lib/cli.jsx --presets es2015,stage-0'
const cwd = process.cwd()
const onRestart = `${executor} build --invalid`
const port = 4000

const restart = () =>
  exec(onRestart, { cwd: './' }, (err2, stdout, stderr) => { // should invoke build, not start a new process
    if (err2) { throw err2 }
    if (stderr) { log.error(stderr) }
    if (stdout) { log.info(stdout) }
  })

const watch = () =>
  new Promise((resolve, reject) => {
    const ops = path.join(cwd, conf.dist, 'OPS')
github reapp / reapp-ui / server.js View on Github external
function runDevelopmentServer() {
  var webpackServer = require('./webpack/server');
  var hostname = 'localhost';
  // hostname = os.hostname();
  yargs.hostname = hostname;

  webpackServer.run(webpackConfig, yargs, function(template) {
    app.get('*', function(req, res) {
      res.send(template);
    });
    runServer();
  });
}
github FNNDSC / ami / gulpfile.js View on Github external
gulp.task('js-examples', function(cb) {
  // process files of interest
  var keys = Object.keys(argv);
  if(keys.length === 3){
    target = 'examples/' +  Object.keys(argv)[1] + '/*.js';
  }

  globby([target], function(err, files) {
    if (err) {
      cb(err);
    }
    var tasks = files.map(function(entry) {
          // to remove /app layer
          var index = entry.indexOf('/');
          return browserify(
              {entries: [entry],
                debug: true
              })
            .transform(babelify)
github kittn / generator-kittn / generators / app / templates / gulpfile / tasks / compile-html.js View on Github external
/**
 * Template Compiler
 *
 * @description Compile Twig Files to HTML or copy Structure Files (usefull for PHP or Source Files for a CMS Compiler.
 */

import kc from '../../config.json'
import pkg from '../../package.json'
import gulp from 'gulp'
import gutil from 'gulp-util'
import gulpLoadPlugins from 'gulp-load-plugins'
import errorHandler from '../lib/errorHandler'
import yargs from 'yargs'

const args = yargs.argv
const $ = gulpLoadPlugins()

const compilerHtmlTask = () => {
  const siteEnv = args.env || 'development'

  // Set Base Locals
  const templateLocals = {
    siteTitle: kc.template.globalTitle,
    cssName: pkg.cssFileName,
    assetsCss: kc.templatePath.css,
    assetsImg: kc.templatePath.contentimage,
    assetsJs: kc.templatePath.js,
    assetsCssImg: kc.templatePath.cssimage,
    environment: siteEnv
  };
github arturi / tent / server / index.js View on Github external
#! /usr/bin/env node

const argv = require('yargs').argv
const express = require('express')
const bodyParser = require('body-parser')
const multer = require('multer')
const glob = require('glob')
const fs = require('fs-extra')
const hammock = require('../hammock')

console.log(argv)

const DOCUMENTS_DIR = argv.docs ? argv.docs : `./documents`
const RELATIVE_MEDIA_DIR = argv.relativeMediaDir ? argv.relativeMediaDir : '/s/'
const PUBLIC_DIR = argv.public ? argv.public : `./public`
const PORT = argv.port ? argv.port : 3350
const TEMP_UPLOADS_DIR = `./uploads/`

const hammockOpts = {
  newImageSize: 1600,
  includeOriginalFileName: false,
  publicDir: PUBLIC_DIR ,
  relativeMediaDir: RELATIVE_MEDIA_DIR
}

const upload = multer({ dest: TEMP_UPLOADS_DIR })
const app = express()
github triplecanopy / b-ber / lib / publish.es6 View on Github external
gulp.task('publish', (done) => {

  const book = yargs.argv.input;
  const site = yargs.argv.output;
  const output = path.join(yargs.argv.output, book);

  const dirs = [
    `${book}/_images`,
    `${book}/_javascripts`,
    `${book}/_stylesheets`,
    `${book}/_text`,
  ];

  mkdirp(output, () =>
    dirs.forEach((dir, idx) => cdir(dir, `${slashit(site)}${dir}`, (err) => {
      if (err) { throw err; }
      if (idx === dirs.length - 1) { done(); }
    }))
  );
github epam / pipeline-builder / gulpfile.babel.js View on Github external
function remoteAccess() {
  if (!yargs.argv.server) {
    util.log('Skipping deployment,', util.colors.red('--server is not specified.'));
    return null;
  }

  const uo = url.parse(yargs.argv.server);
  const auth = (uo.auth || 'anonymous:anonymous@').split(':');

  const conn = ftp.create({
    host: uo.host,
    user: auth[0],
    password: auth[1],
    log: util.log,
    timeOffset: yargs.argv.serverTime ? yargs.argv.serverTime : 0,
  });
  return { conn, path: uo.pathname };
}
github frontend / generator-toolbox / generators / app / templates / tasks / server.js View on Github external
));

  gulp.watch([
    `${config.assets}img/**/*`,
    `${config.assets}svg/**/*`
  ], gulp.series(
    img,
    yargs.argv.production ? inprod : require('./metalsmith').metalsmith,
    reload
  ));

  gulp.watch([
    `${config.assets}icons/**/*`
  ], gulp.series(
    icons,
    yargs.argv.production ? inprod : require('./metalsmith').metalsmith,
    reload
  ));

  gulp.watch([
    `${config.assets}js/**/*.js`
  ], gulp.series(scripts));

  gulp.watch([
    `${config.assets}components/**/*.{html,hbs,md,swig}`,
    `${config.assets}templates/**/*.{html,hbs,md,swig}`,
    `${config.assets}docs/**/*.md`,
    `${config.assets}data/**/*.{json,yml}`
  ], gulp.series(
    yargs.argv.production ? inprod : require('./metalsmith').metalsmithDocs,
    reload
  ));
github gajus / bundle-dependencies / src / index.js View on Github external
prepublish,
    postpublish
} from './commands';

let argv,
    command;

yargs
    .usage('$0 command')
    .command('extract')
    .command('publish')
    .command('prepublish')
    .command('postpublish')
    .demand(1, 'Must provide a valid command.');

argv = yargs.argv;

command = argv._[0];

if (command === 'extract') {
    extract();
} else if (command === 'publish') {
    publish();
} else if (command === 'prepublish') {
    prepublish();
} else {
    postpublish();
}
github s-yadav / relative-to-alias / src / index.js View on Github external
alias: 'i',
    describe: 'If true it will replace path to alias for the alias path directory.',
    type: 'boolean',
    default: false
  })
  .option('ignore', {
    describe: 'Exclude given glob paths for the parsing.',
    type: 'array',
    default: ['./**/node_modules/**'],
  })
  .required(['src', 'alias', 'alias-path']);

yargs.help();


const {rootPath, src, alias, aliasPath, extensions, includeAliasPathDirectory, ignore, language} = yargs.argv;

const aliasRelativeToRoot = path.relative(rootPath, aliasPath);

const srcGlob = getSourceGlob(src, extensions);


glob(srcGlob, { ignore: getIgnoreGlobs(srcGlob, ignore) }, (err, files) =>  {
  //changes files to relative to root path
  files = files.map((file) => {
    return path.relative(rootPath, file);
  });

  //exclude files inside the alias path directory based on includeAliasPathDirectory flag
  if (!includeAliasPathDirectory) {
    files = excludeAliasPathFiles(files, aliasRelativeToRoot);
  }