diff options
| author | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
|---|---|---|
| committer | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
| commit | 7a52ddeba2a68388b544f529d2d92104420f77b0 (patch) | |
| tree | 15ddd47457a2cb4a96060747437d36474e4f6b4e /node_modules/nunjucks/bin | |
| parent | 53d6ae2b5568437afa5e4995580a3fb679b7b91b (diff) | |
Changed from static to 11ty!
Diffstat (limited to 'node_modules/nunjucks/bin')
| -rwxr-xr-x | node_modules/nunjucks/bin/precompile | 58 | ||||
| -rw-r--r-- | node_modules/nunjucks/bin/precompile.cmd | 5 |
2 files changed, 63 insertions, 0 deletions
diff --git a/node_modules/nunjucks/bin/precompile b/node_modules/nunjucks/bin/precompile new file mode 100755 index 0000000..1708235 --- /dev/null +++ b/node_modules/nunjucks/bin/precompile @@ -0,0 +1,58 @@ +#!/usr/bin/env node +var {program} = require('commander'); +var precompile = require('../src/precompile').precompile; +var Environment = require('../src/environment').Environment; +var lib = require('../src/lib'); + +var cmdpath = null; + +program + .storeOptionsAsProperties(false) + .passCommandToAction(false); + +program + .name('precompile') + .usage('[-f|--force] [-a|--filters <filters>] [-n|--name <name>] [-i|--include <regex>] [-x|--exclude <regex>] [-w|--wrapper <wrapper>] <path>') + .arguments('<path>') + .helpOption('-?, -h, --help', 'Display this help message') + .option('-f, --force', 'Force compilation to continue on error') + .option('-a, --filters <filters>', 'Give the compiler a comma-delimited list of asynchronous filters, required for correctly generating code') + .option('-n, --name <name>', 'Specify the template name when compiling a single file') + .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$']) + .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, []) + .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")') + .action(function (path) { + cmdpath = path; + }) + .parse(process.argv); + +function concat(value, previous) { + return previous.concat(value); +} + +if (cmdpath == null) { + program.outputHelp(); + console.error('\nerror: no path given'); + process.exit(1); +} + +var env = new Environment([]); + +const opts = program.opts(); + +lib.each([].concat(opts.filters).join(',').split(','), function (name) { + env.addFilter(name.trim(), function () {}, true); +}); + +if (opts.wrapper) { + opts.wrapper = require('nunjucks-' + opts.wrapper).wrapper; +} + +console.log(precompile(cmdpath, { + env : env, + force : opts.force, + name : opts.name, + wrapper: opts.wrapper, + include : [].concat(opts.include), + exclude : [].concat(opts.exclude) +})); diff --git a/node_modules/nunjucks/bin/precompile.cmd b/node_modules/nunjucks/bin/precompile.cmd new file mode 100644 index 0000000..0e49bce --- /dev/null +++ b/node_modules/nunjucks/bin/precompile.cmd @@ -0,0 +1,5 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\precompile" %* +) ELSE ( + node "%~dp0\precompile" %* +)
\ No newline at end of file |
