HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-172-31-4-197 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/myc/api-management/node_modules/juice/lib/cli.js
'use strict';

var { program } = require('commander');
var pkg = require('../package');

var cli = {};

module.exports = cli;

cli.getProgram = function() {
  program.name = pkg.name;

  program.version(pkg.version)
    .usage('[options] input.html output.html');

  Object.keys(cli.options).forEach(function(key) {
    program.option('--' + key + ' [value]', cli.options[key].def);
  });

  program.parse(process.argv);

  return program;
};

cli.options = {
  'css': {
    pMap: 'css',
    map: 'cssFile',
    def: 'Add an extra CSS file by name' },
  'options-file': {
    pMap: 'optionsFile',
    def: 'Load options from a JSON file' },
  'extra-css': {
    pMap: 'extraCss',
    def: 'Add extra CSS' },
  'insert-preserved-extra-css': {
    pMap: 'insertPreservedExtraCss',
    def: 'insert preserved @font-face and @media into document?',
    coercion: JSON.parse },
  'apply-style-tags': {
    pMap: 'applyStyleTags',
    def: 'inline from style tags?',
    coercion: JSON.parse },
  'remove-style-tags': {
    pMap: 'removeStyleTags',
    def: 'remove style tags?',
    coercion: JSON.parse },
  'preserve-important': {
    pMap: 'preserveImportant',
    def: 'preserve important?',
    coercion: JSON.parse },
  'preserve-media-queries': {
    pMap: 'preserveMediaQueries',
    def: 'preserve media queries?',
    coercion: JSON.parse },
  'preserve-font-faces': {
    pMap: 'preserveFontFaces',
    def: 'preserve font faces?',
    coercion: JSON.parse },
  'preserve-key-frames': {
    pMap: 'preserveKeyFrames',
    def: 'preserve key frames?',
    coercion: JSON.parse },
  'preserve-pseudos': {
    pMap: 'preservePseudos',
    def: 'preserve pseudo selectors?',
    coercion: JSON.parse },
  'apply-width-attributes': {
    pMap: 'applyWidthAttributes',
    def: 'apply width attributes to relevent elements?',
    coercion: JSON.parse },
  'apply-height-attributes': {
    pMap: 'applyHeightAttributes',
    def: 'apply height attributes to relevent elements?',
    coercion: JSON.parse },
  'apply-attributes-table-elements': {
    pMap: 'applyAttributesTableElements',
    def: 'apply attributes with and equivalent CSS value to table elements?',
    coercion: JSON.parse },
  'xml-mode': {
    pMap: 'xmlMode',
    def: 'generate output with tags closed?  input must be valid XML',
    coercion: JSON.parse },
  'resolve-css-variables': {
    pMap: 'resolveCSSVariables',
    def: 'resolve CSS variables',
    coercion: JSON.parse },
  'web-resources-inline-attribute': {
    pMap: 'webResourcesInlineAttribute',
    map: 'inlineAttribute',
    def: 'see docs for web-resource-inliner inlineAttribute',
    coercion: JSON.parse },
  'web-resources-images': {
    pMap: 'webResourcesImages',
    map: 'images',
    def: 'see docs for web-resource-inliner images',
    coercion: JSON.parse },
  'web-resources-links': {
    pMap: 'webResourcesLinks',
    map: 'links',
    def: 'see docs for web-resource-inliner links',
    coercion: JSON.parse },
  'web-resources-scripts': {
    pMap: 'webResourcesScripts',
    map: 'scripts',
    def: 'see docs for web-resource-inliner scripts',
    coercion: JSON.parse },
  'web-resources-relative-to': {
    pMap: 'webResourcesRelativeTo',
    map: 'relativeTo',
    def: 'see docs for web-resource-inliner relativeTo' },
  'web-resources-rebase-relative-to': {
    pMap: 'webResourcesRebaseRelativeTo',
    map: 'rebaseRelativeTo',
    def: 'see docs for web-resource-inliner rebaseRelativeTo' },
  'web-resources-strict': {
    pMap: 'webResourcesStrict',
    map: 'strict',
    def: 'see docs for web-resource-inliner strict',
    coercion: JSON.parse }
};

cli.argsToOptions = function(program) {
  var result = { webResources: {} };
  Object.keys(cli.options).forEach(function(key) {
    var option = cli.options[key];
    var value = program[option.pMap];
    if (value !== undefined) {
      if (option.coercion) {
        value = option.coercion(value);
      }

      if (option.pMap.match(/webResources/)) {
        result.webResources[option.map] = value;
      } else {
        result[option.map || option.pMap] = value;
      }
    }
  });

  return result;
};