Skip to content

Commit

Permalink
feat(cli): debug option
Browse files Browse the repository at this point in the history
  • Loading branch information
Anber committed Feb 10, 2024
1 parent 2d685fc commit 1023a52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gentle-worms-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@wyw-in-js/cli': patch
---

`debug` option for CLI.
12 changes: 11 additions & 1 deletion packages/cli/src/wyw-in-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const argv = yargs
requiresArg: true,
coerce: path.resolve,
})
.option('debug', {
alias: 'd',
type: 'string',
description: 'Path for debug output',
coerce: path.resolve,
})
.option('out-dir', {
alias: 'o',
type: 'string',
Expand Down Expand Up @@ -96,6 +102,7 @@ const argv = yargs

type Options = {
configFile?: string;
debug?: string;
ignore?: string;
insertCssRequires?: string;
modules: (typeof modulesOptions)[number];
Expand Down Expand Up @@ -124,7 +131,9 @@ function resolveOutputFilename(
}

async function processFiles(files: (number | string)[], options: Options) {
const { emitter, onDone } = createFileReporter();
const { emitter, onDone } = createFileReporter(
options.debug ? { dir: options.debug, print: true } : false
);

const resolvedFiles = files.reduce(
(acc, pattern) => [
Expand Down Expand Up @@ -264,6 +273,7 @@ async function processFiles(files: (number | string)[], options: Options) {

processFiles(argv._, {
configFile: argv.config,
debug: argv.debug,
ignore: argv.ignore,
insertCssRequires: argv['insert-css-requires'],
modules: argv.modules,
Expand Down

0 comments on commit 1023a52

Please sign in to comment.