From 35e0531317dcf94fcb85362b04934d2e24e7d242 Mon Sep 17 00:00:00 2001 From: solufa Date: Sun, 18 Aug 2024 00:33:15 +0900 Subject: [PATCH] refactor: use watchInputDir instead of chokidar --- package-lock.json | 1 - package.json | 1 - src/cli.ts | 6 +++--- src/watchIndexFiles.ts | 7 ------- 4 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 src/watchIndexFiles.ts diff --git a/package-lock.json b/package-lock.json index cb9227f..459e080 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "MIT", "dependencies": { "aspida": "^1.14.0", - "chokidar": "^3.6.0", "openapi-types": "^12.1.3", "typescript-json-schema": "^0.64.0" }, diff --git a/package.json b/package.json index f0ad859..5878abe 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ ], "dependencies": { "aspida": "^1.14.0", - "chokidar": "^3.6.0", "openapi-types": "^12.1.3", "typescript-json-schema": "^0.64.0" }, diff --git a/src/cli.ts b/src/cli.ts index c154054..5a81719 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,8 +1,8 @@ import { getConfigs } from 'aspida/dist/cjs/getConfigs'; +import watchInputDir from 'aspida/dist/cjs/watchInputDir'; import minimist from 'minimist'; import build from '.'; import type { ConfigFile, PartialConfig } from './getConfig'; -import { watchIndexFiles } from './watchIndexFiles'; export const run = (args: string[]) => { const argv: Record = minimist(args, { @@ -21,7 +21,7 @@ export const run = (args: string[]) => { build(configs); if (argv.watch !== undefined) { - configs.forEach((config) => watchIndexFiles(config.input, () => build(config))); + configs.forEach((config) => watchInputDir(config.input, () => build(config))); } return; @@ -38,5 +38,5 @@ export const run = (args: string[]) => { build(option); - if (argv.watch !== undefined) watchIndexFiles(config.input, () => build(option)); + if (argv.watch !== undefined) watchInputDir(config.input, () => build(option)); }; diff --git a/src/watchIndexFiles.ts b/src/watchIndexFiles.ts deleted file mode 100644 index ab0c945..0000000 --- a/src/watchIndexFiles.ts +++ /dev/null @@ -1,7 +0,0 @@ -import chokidar from 'chokidar'; - -export const watchIndexFiles = (dir: string, callback: () => void) => { - chokidar - .watch(`${dir.replace(/\/$/, '')}/**/index.ts`, { ignoreInitial: true }) - .on('all', callback); -};