How to use the commander.file function in commander

To help you get started, we’ve selected a few commander 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 SphinxKnight / compat-tester / bin / compat-tester.js View on Github external
commander.scope = commander.args.find(el => el.endsWith(".json")) || "scope.json";
        commander.file = commander.args.find(el => el.endsWith(".html")) || "index.html";
    }
}

// Convert different options into an object
const options = {
    "contrib": commander.contribute
    // Might add other secondary options to this
};

const scope = JSON.parse(fs.readFileSync(commander.scope, "utf-8"));

if(!commander.html && !commander.css && !commander.url){
    // Let's parse the HTML
    htmlAnalyzer.analyzeFile(commander.file, scope, (e, d) => {
        if (e) {
            console.error(e);
            return false;
        }
        const report = d;
        console.log("HTML Report:");
        // report =[ {"browser " / "filename" / "line" / "column" / "featureName" / "minVer"]
        report.sort(reportHelpers.sortReport);
        report.map(reportHelpers.printReportLine);
    }, options);


    // Let's get the CSS inside the site
    cssExtracter.analyzeFile(commander.file, (e, acc) => {
        acc.map(async (block) => {
            cssAnalyzer.analyzeString(await block.content, scope, block.lineShift, block.fileName, (e, d) => {
github tidepool-org / uploader / lib / drivers / abbott / cli / fslibre.js View on Github external
function readDataFromFile() {
  console.log(intro, 'Reading JSON data from:', program.file);
  return JSON.parse(fs.readFileSync(program.file, 'utf8'), (k, v) => {
    if (v !== null && typeof v === 'object' && 'type' in v &&
      v.type === 'Buffer' && 'data' in v && Array.isArray(v.data)) {
      // re-create Buffer objects for data fields of aapPackets
      return Buffer.from(v.data);
    }
    return v;
  });
}
github bucharest-gold / szero / bin / szero.js View on Github external
.parse(process.argv);

if (program.args.length === 0) {
  program.help();
}

// Default the console option when calling from the command line
const options = {
  consoleReporter: true
};

if (program.silent) {
  options.consoleReporter = false;
}

options.fileReporter = program.file;

if (program.filename) {
  options.filename = program.filename;
  options.fileReporter = true;
}

if (program.ignore) {
  options.ignore = program.ignore.split(',').map((d) => d.trim());
}

options.ci = program.ci;
options.dev = program.dev;

options.license = program.license;

if (program.summary) {
github duckduckgo / duckduckgo-privacy-extension / selenium-test / ratings.js View on Github external
async function runTest(opts) {
    if (program.number) {
        await testRatings.testTopSites(program.number, opts);
    } else if (program.file) {
        if (fs.existsSync(program.file)) {
            let text = fs.readFileSync(program.file, "utf8");
            let urlArray = text.split(/\r?\n/);
            await testRatings.testUrls(urlArray, opts);
        } else {
            console.error(`Could not read ${program.file}`);
        }
    } else if (program.url) {
        await testRatings.testUrl(program.url, opts);
    } else {
        program.help();
    }
}
github weexteam / devtool-for-Apache-Weex / scripts / weex-devtool.js View on Github external
function buildAndStart () {
  if (/^https?:\/\//.test(Program.file)) {
    const url = Program.file.replace(/^(https?:\/\/)([^/:]+)(?=:\d+|\/)/, function (m, a, b) {
      if (!/\d+\.\d+\.\d+\.\d+/.test(a)) {
        return a + Hosts.findRealHost(b);
      }
      else {
        return m;
      }
    });
    Config.entryBundleUrl = url;
    startServerAndLaunchDevtool();
  }
  else {
    const filePath = Path.resolve(Program.file);
    const ext = Path.extname(filePath);
    if (!Fs.existsSync(filePath)) {
      console.error(filePath + ': No such file or directory');
      return Exit(0);
github StarpTech / branch-comparer / index.js View on Github external
return new Promise((resolve, reject) => {
    const command = spawn(cmd, {
      stdio: mode ? 'pipe' : 'inherit',
      shell: true,
      encoding: 'utf-8'
    })

    if (Program.file) {
      command.stdout.pipe(
        Fs.createWriteStream(`branch.${branch}.round-${round + 1}.log`)
      )
    }

    command.on('close', code => {
      console.log(
        Chalk.grey(`Executed: "${cmd}" and exited with code: ${code}`)
      )
      resolve()
    })
  })
}
github vega / vega-lite / bin / gen.js View on Github external
var program = require('commander');
program.version('0.0.1')
  .description('Generate Test Cases. Regenerate all testcases in ' + VEGA_DIR + ' by default.  Use -f or -j to generate single test case.')
  .option('-j, --json [string]', 'Create test from json strings [null]', null)
  .option('-f, --file [path]', 'Create test from file [null]', null)
  .option('-d, --data [path]', 'Data file path (otherwise, path will be parsed from dataUrl config.) [null]', null)
  .option('-n, --note [String]', 'Add _info.description property to the vega-lite json file.', null)
  .parse(process.argv);

var fs = require('fs'),
  vl = require('../vega-lite.js'),
  stringify = require('../lib/json3-compactstringify').stringify;

if (program.json || program.file) {
  var json = program.json ? JSON.parse(program.json) : require(program.file),
    encoding = vl.Encoding.fromSpec(json);

  if (program.note) {
    (encoding._info = encoding._info  || {}).description = program.note;
  }

  generate(encoding, 'specs');
}else {
  var testcases = require('./testcases');

  vl.keys(testcases).forEach(function(dataUrl) {
    testcases[dataUrl].forEach(function(tc) {
      var encoding = vl.Encoding.parseShorthand(tc.e, {dataUrl: dataUrl});
      encoding._info = {
        description: tc.n
      };
github weexteam / devtool-for-Apache-Weex / bin / weex-devtool.js View on Github external
buildFileAndWatchIt(Program.mode, filePath).then(function () {
        startServerAndLaunchDevtool(Program.file);
      }, function (err) {
        if (err) {