All files / src/commands CompileCommand.ts

85% Statements 17/20
68.75% Branches 11/16
50% Functions 1/2
89.47% Lines 17/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2924x     24x 24x 24x 24x 2x   2x 2x   2x 2x       2x 2x 2x 2x     2x 2x   2x    
import { argdown, IFileRequest, ISaveAsRequest } from "@argdown/node";
import { Arguments } from "yargs";
 
export const command = "compile [inputGlob] [outputDir]";
export const desc = "compile included Argdown files into main file";
export const builder = {};
export const handler = async (argv: Arguments) => {
  let config = <IFileRequest & ISaveAsRequest>await argdown.loadConfig(argv.config);
 
  Eif (argv.inputGlob) {
    config.inputPath = argv.inputGlob;
  }
  config.saveAs = config.saveAs || {};
  Iif (argv.outputDir) {
    config.saveAs.outputDir = argv.outputDir;
  }
 
  config.logLevel = argv.verbose ? "verbose" : config.logLevel;
  config.watch = argv.watch || config.watch;
  config.process = ["load-file"];
  Iif (!argv.stdout || argv.outputDir) {
    config.process.push("save-as-argdown");
  }
  Eif (argv.stdout) {
    config.process.push("stdout-argdown");
  }
  await argdown.load(config).catch((e: Error) => console.log(e));
};