[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/sake92/node-htmlprocessor/master/bin/htmlprocessor [Back]  [Original]

#!/usr/bin/env node

/*
 * node-htmlprocessor
 * https://github.com/dciccale/node-htmlprocessor
 *
 * Copyright (c) 2013-2016 Denis Ciccale (@dciccale)
 * Licensed under the MIT license.
 * https://github.com/dciccale/node-htmlprocessor/blob/master/LICENSE-MIT
 */

var path = require('path');
var index = require('../index');
var pkg = require('../package.json');
var args = process.argv.slice(2);
var options = {};
var files = [];
var output;

while (args.length > 0) {
  var v = args.shift();

  switch (v) {
    case '-d':
    case '--data':
      options.data = require(path.resolve(args.shift()));
      break;
    case '-e':
    case '--env':
      options.environment = args.shift();
      break;
    case '-c':
    case '--comment-marker':
      options.commentMarker = args.shift();
      break;
    case '-i':
    case '--include-base':
      options.includeBase = args.shift();
      break;
    case '-l':
    case '--list':
      options.list = args.shift();
      break;
    case '-r':
    case '--recursive':
      options.recursive = args.shift();
      break;
    case '-s':
    case '--strip':
      options.strip = true;
      break;
    case '-v':
    case '--version':
      console.log(pkg.version);
      process.exit(0);
      break;
    case '-o':
    case '--output':
      output = args.shift();
      break;
    case '--custom-block-type':
      options.customBlockTypes = [args.shift()];
      break;
    case '-h':
    case '--help':
      console.log('Usage: htmlprocessor file-to-process.html [options]\n');
      console.log('  -h, --help             display this help message');
      console.log('  -v, --version          display the version number');
      console.log('  -l, --list             file to output list of replaced files');
      console.log('  -o, --output           file to output processed HTML to');
      console.log('  -d, --data             pass a JSON file to processor');
      console.log('  -e, --env              specify an environment');
      console.log('  -r, --recursive        recursive processing');
      console.log('  -c, --comment-marker   change the comment marker');
      console.log('  -i, --include-base     set the directory to include files from');
      console.log('  -s, --strip            strip blocks matched by other environments');
      console.log('  --custom-block-type    specify custom block type');
      break;
    default:
      if (v && v.indexOf('-') === 0) {
        throw ('Unknown option: ' + v);
      }
      files.push(v);
  }
}

index({src: files, dest: output}, options);

Web Proxy Viewer  |  New URL  |  Original Page