Skip to content

Commit

Permalink
feat(meta-css): update generate cmd input handling
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 28, 2023
1 parent 5d8e2fc commit c156762
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/meta-css/src/generate.ts
Expand Up @@ -3,7 +3,7 @@ import type { Fn, Fn2, IObjectOf, NumOrString } from "@thi.ng/api";
import { int, type Command } from "@thi.ng/args";
import { isArray, isPlainObject, isString } from "@thi.ng/checks";
import { illegalArgs } from "@thi.ng/errors";
import { files, readJSON } from "@thi.ng/file-io";
import { readJSON } from "@thi.ng/file-io";
import {
deg,
em,
Expand All @@ -24,7 +24,6 @@ import {
} from "@thi.ng/hiccup-css";
import type { ILogger } from "@thi.ng/logger";
import { permutations } from "@thi.ng/transducers";
import { statSync } from "fs";
import { resolve } from "path";
import {
ARG_PRETTY,
Expand Down Expand Up @@ -87,25 +86,21 @@ export const GENERATE: Command<
...ARG_PRETTY,
prec: int({ default: 3, desc: "Number of fractional digits" }),
},
inputs: 1,
fn: async (ctx) => {
const {
logger,
opts: { prec, out, pretty },
inputs,
} = ctx;
const root = resolve(inputs[0]);
if (!statSync(root).isDirectory())
illegalArgs(`${root} is not a directory`);
const result: CompiledSpecs = {
info: { name: "TODO", version: "0.0.0" },
media: {},
classes: {},
decls: [],
};
setPrecision(prec);
for (let input of files(root, ".json")) {
const config = readJSON<GeneratorConfig>(input, logger);
for (let input of inputs) {
const config = readJSON<GeneratorConfig>(resolve(input), logger);
Object.assign(result.info, config.info);
Object.assign(result.media, config.media);
if (config.decls) result.decls.push(...config.decls);
Expand Down

0 comments on commit c156762

Please sign in to comment.