Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

precompile 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env node
  2. var {program} = require('commander');
  3. var precompile = require('../src/precompile').precompile;
  4. var Environment = require('../src/environment').Environment;
  5. var lib = require('../src/lib');
  6. var cmdpath = null;
  7. program
  8. .storeOptionsAsProperties(false)
  9. .passCommandToAction(false);
  10. program
  11. .name('precompile')
  12. .usage('[-f|--force] [-a|--filters <filters>] [-n|--name <name>] [-i|--include <regex>] [-x|--exclude <regex>] [-w|--wrapper <wrapper>] <path>')
  13. .arguments('<path>')
  14. .helpOption('-?, -h, --help', 'Display this help message')
  15. .option('-f, --force', 'Force compilation to continue on error')
  16. .option('-a, --filters <filters>', 'Give the compiler a comma-delimited list of asynchronous filters, required for correctly generating code')
  17. .option('-n, --name <name>', 'Specify the template name when compiling a single file')
  18. .option('-i, --include <regex>', 'Include a file or folder which match the regex but would otherwise be excluded. You can use this flag multiple times', concat, ['\\.html$', '\\.jinja$'])
  19. .option('-x, --exclude <regex>', 'Exclude a file or folder which match the regex but would otherwise be included. You can use this flag multiple times', concat, [])
  20. .option('-w, --wrapper <wrapper>', 'Load a external plugin to change the output format of the precompiled templates (for example, "-w custom" will load a module named "nunjucks-custom")')
  21. .action(function (path) {
  22. cmdpath = path;
  23. })
  24. .parse(process.argv);
  25. function concat(value, previous) {
  26. return previous.concat(value);
  27. }
  28. if (cmdpath == null) {
  29. program.outputHelp();
  30. console.error('\nerror: no path given');
  31. process.exit(1);
  32. }
  33. var env = new Environment([]);
  34. const opts = program.opts();
  35. lib.each([].concat(opts.filters).join(',').split(','), function (name) {
  36. env.addFilter(name.trim(), function () {}, true);
  37. });
  38. if (opts.wrapper) {
  39. opts.wrapper = require('nunjucks-' + opts.wrapper).wrapper;
  40. }
  41. console.log(precompile(cmdpath, {
  42. env : env,
  43. force : opts.force,
  44. name : opts.name,
  45. wrapper: opts.wrapper,
  46. include : [].concat(opts.include),
  47. exclude : [].concat(opts.exclude)
  48. }));