Refactor template.js

Added:
- Function `resolve()` to process any template tags (in a string) in objects and arrays.

Changed:
- Renamed function `template()` to `resolveValue()`.
- Replaced default export `resolveValue()` with new function `resolve()`.
This commit is contained in:
Chauncey McAskill
2022-03-22 16:08:29 -04:00
parent d49d3eabb2
commit 48bd911804
6 changed files with 63 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
import loconfig from '../../loconfig.json';
import message from '../utils/message.js';
import notification from '../utils/notification.js';
import template from '../utils/template.js';
import resolve from '../utils/template.js';
import esbuild from 'esbuild';
import { basename } from 'node:path';
@@ -67,12 +67,12 @@ export default async function compileScripts(esBuildOptions = null) {
console.time(timeLabel);
try {
includes = includes.map((path) => template(path));
includes = resolve(includes);
if (outdir) {
outdir = template(outdir);
outdir = resolve(outdir);
} else if (outfile) {
outfile = template(outfile);
outfile = resolve(outfile);
} else {
throw new TypeError(
'Expected \'outdir\' or \'outfile\''