Skip to content

Commit 3f52e6d

Browse files
committed
feat: add silent option
1 parent 56bf339 commit 3f52e6d

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ For more info, run any command with the `--help` flag:
3030
3131
Options:
3232
--cwd [path] Set fix directory (default: dist)
33-
--dts Fix commonjs d.ts files (default: true)
33+
--dts Fix commonjs d.ts and d.cts files (default: true)
3434
-i, --ignore [...files] Ignore files
35+
--silent Suppress logs
3536
-v, --version Display version number
3637
-h, --help Display this message
3738
```

src/cli.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ cli
1515
.option('--cwd [path]', 'Set fix directory', { default: 'dist' })
1616
.option('--dts', 'Fix commonjs d.ts and d.cts files', { default: true })
1717
.option('-i, --ignore [...files]', 'Ignore files')
18+
.option('--silent', 'Suppress logs')
1819
.action(async (files, options) => {
19-
const { dts } = options;
20+
const { dts, silent } = options;
2021
const hasCustomMatchFiles = !!files?.length;
2122
const currentDir = process.cwd();
2223
const cwd = path.resolve(currentDir, options.cwd);
@@ -29,6 +30,8 @@ cli
2930
cwd: hasCustomMatchFiles ? currentDir : cwd,
3031
ignore,
3132
},
33+
34+
silent,
3235
});
3336

3437
if (dts) {
@@ -37,6 +40,8 @@ cli
3740
cwd,
3841
ignore,
3942
},
43+
44+
silent,
4045
});
4146
}
4247
});

src/reflect.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ export interface ReflectOptions {
1010
globOptions?: fg.Options;
1111
name?: string;
1212
reflect(code: string): Promise<ReflectActionResult> | ReflectActionResult;
13+
silent?: boolean;
1314
}
1415

1516
export const reflect = async (options: ReflectOptions) => {
16-
const { globOptions = {}, name = 'reflect', reflect } = options;
17+
const { globOptions = {}, name = 'reflect', reflect, silent } = options;
1718
const cwd = process.cwd();
1819

1920
const files = await fg(options.files, {
@@ -23,7 +24,9 @@ export const reflect = async (options: ReflectOptions) => {
2324
ignore: [...(globOptions.ignore || []), 'node_modules'],
2425
});
2526

26-
const logger = (message: string) => console.log(`[${name}]`, message);
27+
const logger = (message: string) => {
28+
if (!silent) console.log(`[${name}]`, message);
29+
};
2730

2831
if (!files.length) logger(gray('No files matched'));
2932

0 commit comments

Comments
 (0)