How to use the cli.native function in cli

To help you get started, we’ve selected a few cli 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 smfoote / tornado / bin / tornado.es6 View on Github external
function output(data, file) {
  let outputStream;
  try {
    if (file) {
      if (streams[file]) {
        outputStream = streams[file];
      } else {
        outputStream = streams[file] = cli.native.fs.createWriteStream(file);
      }
    } else {
      outputStream = process.stdout;
    }
    outputStream.write(data + cli.native.os.EOL);
  } catch (e) {
    cli.fatal('Could not write to output stream');
  }
}
github smfoote / tornado / bin / tornado.es6 View on Github external
function output(data, file) {
  let outputStream;
  try {
    if (file) {
      if (streams[file]) {
        outputStream = streams[file];
      } else {
        outputStream = streams[file] = cli.native.fs.createWriteStream(file);
      }
    } else {
      outputStream = process.stdout;
    }
    outputStream.write(data + cli.native.os.EOL);
  } catch (e) {
    cli.fatal('Could not write to output stream');
  }
}
github smfoote / tornado / bin / tornado.es6 View on Github external
cli.setUsage(`${cli.app} [options] [path1 [path2 path3]]

  Compile all .td files in a directory:
${cli.app} --output=compiled.js templates/**/*.td`);

cli.parse({
  name: ['n', 'The name by which the template will be registered (defaults to path)', 'string'],
  output: ['o', 'Concatenate all output to this file', 'path'],
  split: ['s', 'Should the output files be split into their own files (true) or concatenated (false)', 'boolean'],
  pwd: [false, 'generate template names starting from this directory', 'string'],
  mode: ['m', 'Compling for `production` or `dev`', 'string']
});

let streams;
let path = cli.native.path;

function glob(globPaths) {
  return globPaths.map(arg => cli.glob.sync(arg))
    .reduce((a, b) => a.concat(b), []);
}

function read(filename, cb) {
  var data = '',
    file = fs.createReadStream(filename);

  file.on('error', cb);
  file.on('data', function(chunk) {
    data += chunk;
  });
  file.on('end', function() {
    cb(null, data);