From a87c85cf52ceaddcc0b36b2432c230017edc8046 Mon Sep 17 00:00:00 2001 From: Tobias Lundin Date: Mon, 20 Dec 2021 14:31:10 +0100 Subject: [PATCH 1/2] only handle .css files Chokidar can trigger `writeFile` for files that `glob()` does not, so add extra precaution here to skip avoidable error logs --- src/run.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/run.ts b/src/run.ts index 8ac660fd..4e20d983 100644 --- a/src/run.ts +++ b/src/run.ts @@ -31,6 +31,9 @@ export async function run(searchDir: string, options: RunOptions = {}): Promise< }); const writeFile = async (f: string): Promise => { + if (!f.endsWith('.css')) { + return; + } try { const content: DtsContent = await creator.create(f, undefined, !!options.watch); await content.writeFile(); From cb89e0f10a90a29c78d0a1841c5761cc8755f2aa Mon Sep 17 00:00:00 2001 From: Tobias Lundin Date: Mon, 20 Dec 2021 14:44:04 +0100 Subject: [PATCH 2/2] use regex instead --- src/run.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/run.ts b/src/run.ts index 4e20d983..4c7515f2 100644 --- a/src/run.ts +++ b/src/run.ts @@ -7,6 +7,7 @@ import { DtsCreator } from './dts-creator'; import { DtsContent } from './dts-content'; const glob = util.promisify(_glob); +const cssExtRegex = /\.css$/i; interface RunOptions { pattern?: string; @@ -31,7 +32,7 @@ export async function run(searchDir: string, options: RunOptions = {}): Promise< }); const writeFile = async (f: string): Promise => { - if (!f.endsWith('.css')) { + if (!cssExtRegex.test(f)) { return; } try {