i18next-cli 1.11.13 → 1.11.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.11.14](https://github.com/i18next/i18next-cli/compare/v1.11.13...v1.11.14) - 2025-10-22
9
+
10
+ - Better Fix for: Stop infinite watch loops by properly honoring extract.ignore patterns [#70](https://github.com/i18next/i18next-cli/issues/70)
11
+
8
12
  ## [1.11.13](https://github.com/i18next/i18next-cli/compare/v1.11.12...v1.11.13) - 2025-10-22
9
13
 
10
14
  - Fix: Stop infinite watch loops by properly honoring extract.ignore patterns [#70](https://github.com/i18next/i18next-cli/issues/70)
package/dist/cjs/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=require("commander"),t=require("chokidar"),n=require("chalk"),o=require("./config.js"),i=require("./heuristic-config.js"),r=require("./extractor/core/extractor.js");require("glob"),require("node:path"),require("node:fs/promises"),require("jiti");var a=require("./types-generator.js"),c=require("./syncer.js"),s=require("./migrator.js"),l=require("./init.js"),u=require("./linter.js"),g=require("./status.js"),d=require("./locize.js");const p=new e.Command;p.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.13"),p.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async e=>{try{const n=await o.ensureConfig(),i=async()=>{const t=await r.runExtractor(n,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:!!e.syncPrimary});return e.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await i(),e.watch){console.log("\nWatching for changes...");const e=[/node_modules/,...Array.isArray(n.extract.ignore)?n.extract.ignore:n.extract.ignore?[n.extract.ignore]:[]],o=n.extract.input||[];t.watch(o,{ignored:e,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),i()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),p.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(e,t)=>{let r=await o.loadConfig();if(!r){console.log(n.blue("No config file found. Attempting to detect project structure..."));const e=await i.detectConfig();e||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),r=e}await g.runStatus(r,{detail:e,namespace:t.namespace})}),p.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async e=>{const n=await o.ensureConfig(),i=()=>a.runTypesGenerator(n);if(await i(),e.watch){console.log("\nWatching for changes...");const e=[/node_modules/,...Array.isArray(n.extract?.ignore)?n.extract.ignore:n.extract?.ignore?[n.extract?.ignore]:[]],o=n.types?.input||[];t.watch(o,{ignored:e,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),i()})}}),p.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=await o.ensureConfig();await c.runSyncer(e)}),p.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await s.runMigrator(e)}),p.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(l.runInit),p.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async e=>{const r=async()=>{let e=await o.loadConfig();if(!e){console.log(n.blue("No config file found. Attempting to detect project structure..."));const t=await i.detectConfig();t||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),e=t}await u.runLinter(e)};if(await r(),e.watch){console.log("\nWatching for changes...");const e=await o.loadConfig();if(e?.extract?.input){const n=[/node_modules/,...Array.isArray(e.extract.ignore)?e.extract.ignore:e.extract.ignore?[e.extract.ignore]:[]],o=e.extract.input||[];t.watch(o,{ignored:n,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),r()})}}}),p.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async e=>{const t=await o.ensureConfig();await d.runLocizeSync(t,e)}),p.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const t=await o.ensureConfig();await d.runLocizeDownload(t,e)}),p.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const t=await o.ensureConfig();await d.runLocizeMigrate(t,e)}),p.parse(process.argv);
2
+ "use strict";var e=require("commander"),t=require("chokidar"),n=require("glob"),o=require("minimatch"),i=require("chalk"),a=require("./config.js"),r=require("./heuristic-config.js"),c=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti");var s=require("./types-generator.js"),l=require("./syncer.js"),u=require("./migrator.js"),d=require("./init.js"),g=require("./linter.js"),p=require("./status.js"),f=require("./locize.js");const m=new e.Command;m.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.14"),m.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async e=>{try{const n=await a.ensureConfig(),i=async()=>{const t=await c.runExtractor(n,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:!!e.syncPrimary});return e.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await i(),e.watch){console.log("\nWatching for changes...");const e=await w(n.extract.input),a=y(n.extract.ignore),r=h(n.extract.output),c=[...a,...r].filter(Boolean),s=e.filter(e=>!c.some(t=>o.minimatch(e,t,{dot:!0})));t.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),i()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),m.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(e,t)=>{let n=await a.loadConfig();if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await r.detectConfig();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=e}await p.runStatus(n,{detail:e,namespace:t.namespace})}),m.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async e=>{const n=await a.ensureConfig(),i=()=>s.runTypesGenerator(n);if(await i(),e.watch){console.log("\nWatching for changes...");const e=await w(n.types?.input||[]),a=[...y(n.extract?.ignore)].filter(Boolean),r=e.filter(e=>!a.some(t=>o.minimatch(e,t,{dot:!0})));t.watch(r,{persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),i()})}}),m.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=await a.ensureConfig();await l.runSyncer(e)}),m.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await u.runMigrator(e)}),m.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(d.runInit),m.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async e=>{const n=async()=>{let e=await a.loadConfig();if(!e){console.log(i.blue("No config file found. Attempting to detect project structure..."));const t=await r.detectConfig();t||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),e=t}await g.runLinter(e)};if(await n(),e.watch){console.log("\nWatching for changes...");const e=await a.loadConfig();if(e?.extract?.input){const i=await w(e.extract.input),a=[...y(e.extract.ignore),...h(e.extract.output)].filter(Boolean),r=i.filter(e=>!a.some(t=>o.minimatch(e,t,{dot:!0})));t.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),n()})}}}),m.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async e=>{const t=await a.ensureConfig();await f.runLocizeSync(t,e)}),m.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const t=await a.ensureConfig();await f.runLocizeDownload(t,e)}),m.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const t=await a.ensureConfig();await f.runLocizeMigrate(t,e)}),m.parse(process.argv);const y=e=>Array.isArray(e)?e:e?[e]:[],h=e=>e&&"string"==typeof e?[e.replace(/\{\{[^}]+\}\}/g,"*")]:[],w=async(e=[])=>{const t=y(e),o=await Promise.all(t.map(e=>n.glob(e||"",{nodir:!0})));return Array.from(new Set(o.flat()))};
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as t}from"commander";import e from"chokidar";import o from"chalk";import{ensureConfig as n,loadConfig as i}from"./config.js";import{detectConfig as a}from"./heuristic-config.js";import{runExtractor as r}from"./extractor/core/extractor.js";import"glob";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as c}from"./types-generator.js";import{runSyncer as s}from"./syncer.js";import{runMigrator as l}from"./migrator.js";import{runInit as p}from"./init.js";import{runLinter as d}from"./linter.js";import{runStatus as m}from"./status.js";import{runLocizeSync as g,runLocizeDownload as u,runLocizeMigrate as f}from"./locize.js";const y=new t;y.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.13"),y.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async t=>{try{const o=await n(),i=async()=>{const e=await r(o,{isWatchMode:!!t.watch,isDryRun:!!t.dryRun,syncPrimaryWithDefaults:!!t.syncPrimary});return t.ci&&!e?(console.log("✅ No files were updated."),process.exit(0)):t.ci&&e&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),e};if(await i(),t.watch){console.log("\nWatching for changes...");const t=[/node_modules/,...Array.isArray(o.extract.ignore)?o.extract.ignore:o.extract.ignore?[o.extract.ignore]:[]],n=o.extract.input||[];e.watch(n,{ignored:t,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),i()})}}catch(t){console.error("Error running extractor:",t),process.exit(1)}}),y.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(t,e)=>{let n=await i();if(!n){console.log(o.blue("No config file found. Attempting to detect project structure..."));const t=await a();t||(console.error(o.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${o.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(o.green("Project structure detected successfully!")),n=t}await m(n,{detail:t,namespace:e.namespace})}),y.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async t=>{const o=await n(),i=()=>c(o);if(await i(),t.watch){console.log("\nWatching for changes...");const t=[/node_modules/,...Array.isArray(o.extract?.ignore)?o.extract.ignore:o.extract?.ignore?[o.extract?.ignore]:[]],n=o.types?.input||[];e.watch(n,{ignored:t,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),i()})}}),y.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const t=await n();await s(t)}),y.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async t=>{await l(t)}),y.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(p),y.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async t=>{const n=async()=>{let t=await i();if(!t){console.log(o.blue("No config file found. Attempting to detect project structure..."));const e=await a();e||(console.error(o.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${o.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(o.green("Project structure detected successfully!")),t=e}await d(t)};if(await n(),t.watch){console.log("\nWatching for changes...");const t=await i();if(t?.extract?.input){const o=[/node_modules/,...Array.isArray(t.extract.ignore)?t.extract.ignore:t.extract.ignore?[t.extract.ignore]:[]],i=t.extract.input||[];e.watch(i,{ignored:o,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),n()})}}}),y.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async t=>{const e=await n();await g(e,t)}),y.command("locize-download").description("Download all translations from your locize project.").action(async t=>{const e=await n();await u(e,t)}),y.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async t=>{const e=await n();await f(e,t)}),y.parse(process.argv);
2
+ import{Command as t}from"commander";import e from"chokidar";import{glob as o}from"glob";import{minimatch as n}from"minimatch";import i from"chalk";import{ensureConfig as a,loadConfig as r}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as s}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as l}from"./types-generator.js";import{runSyncer as p}from"./syncer.js";import{runMigrator as m}from"./migrator.js";import{runInit as d}from"./init.js";import{runLinter as f}from"./linter.js";import{runStatus as u}from"./status.js";import{runLocizeSync as g,runLocizeDownload as y,runLocizeMigrate as h}from"./locize.js";const w=new t;w.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.11.14"),w.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async t=>{try{const o=await a(),i=async()=>{const e=await s(o,{isWatchMode:!!t.watch,isDryRun:!!t.dryRun,syncPrimaryWithDefaults:!!t.syncPrimary});return t.ci&&!e?(console.log("✅ No files were updated."),process.exit(0)):t.ci&&e&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),e};if(await i(),t.watch){console.log("\nWatching for changes...");const t=await z(o.extract.input),a=x(o.extract.ignore),r=j(o.extract.output),c=[...a,...r].filter(Boolean),s=t.filter(t=>!c.some(e=>n(t,e,{dot:!0})));e.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),i()})}}catch(t){console.error("Error running extractor:",t),process.exit(1)}}),w.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(t,e)=>{let o=await r();if(!o){console.log(i.blue("No config file found. Attempting to detect project structure..."));const t=await c();t||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),o=t}await u(o,{detail:t,namespace:e.namespace})}),w.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async t=>{const o=await a(),i=()=>l(o);if(await i(),t.watch){console.log("\nWatching for changes...");const t=await z(o.types?.input||[]),a=[...x(o.extract?.ignore)].filter(Boolean),r=t.filter(t=>!a.some(e=>n(t,e,{dot:!0})));e.watch(r,{persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),i()})}}),w.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const t=await a();await p(t)}),w.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async t=>{await m(t)}),w.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(d),w.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async t=>{const o=async()=>{let t=await r();if(!t){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await c();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),t=e}await f(t)};if(await o(),t.watch){console.log("\nWatching for changes...");const t=await r();if(t?.extract?.input){const i=await z(t.extract.input),a=[...x(t.extract.ignore),...j(t.extract.output)].filter(Boolean),r=i.filter(t=>!a.some(e=>n(t,e,{dot:!0})));e.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),o()})}}}),w.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async t=>{const e=await a();await g(e,t)}),w.command("locize-download").description("Download all translations from your locize project.").action(async t=>{const e=await a();await y(e,t)}),w.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async t=>{const e=await a();await h(e,t)}),w.parse(process.argv);const x=t=>Array.isArray(t)?t:t?[t]:[],j=t=>t&&"string"==typeof t?[t.replace(/\{\{[^}]+\}\}/g,"*")]:[],z=async(t=[])=>{const e=x(t),n=await Promise.all(e.map(t=>o(t||"",{nodir:!0})));return Array.from(new Set(n.flat()))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.11.13",
3
+ "version": "1.11.14",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -79,6 +79,7 @@
79
79
  "inquirer": "12.9.6",
80
80
  "jiti": "2.6.1",
81
81
  "jsonc-parser": "3.3.1",
82
+ "minimatch": "10.0.3",
82
83
  "ora": "9.0.0",
83
84
  "swc-walk": "1.0.0"
84
85
  }
package/src/cli.ts CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  import { Command } from 'commander'
4
4
  import chokidar from 'chokidar'
5
+ import { glob } from 'glob'
6
+ import { minimatch } from 'minimatch'
5
7
  import chalk from 'chalk'
6
8
  import { loadConfig, ensureConfig } from './config'
7
9
  import { detectConfig } from './heuristic-config'
@@ -20,7 +22,7 @@ const program = new Command()
20
22
  program
21
23
  .name('i18next-cli')
22
24
  .description('A unified, high-performance i18next CLI.')
23
- .version('1.11.13')
25
+ .version('1.11.14')
24
26
 
25
27
  program
26
28
  .command('extract')
@@ -57,14 +59,17 @@ program
57
59
  // If in watch mode, set up the chokidar watcher
58
60
  if (options.watch) {
59
61
  console.log('\nWatching for changes...')
60
- // Respect configured ignore patterns and pass the original glob(s) to chokidar
61
- const ignoredPatterns = [
62
- /node_modules/,
63
- ...(Array.isArray(config.extract.ignore) ? config.extract.ignore : (config.extract.ignore ? [config.extract.ignore] : [])),
64
- ]
65
- const watchTargets = config.extract.input || []
66
- const watcher = chokidar.watch(watchTargets, {
67
- ignored: ignoredPatterns,
62
+ // expand configured input globs (keep original behavior for detection)
63
+ const expanded = await expandGlobs(config.extract.input)
64
+ // build ignore list (configured + derived from output template)
65
+ const configuredIgnore = toArray(config.extract.ignore)
66
+ const derivedIgnore = deriveOutputIgnore(config.extract.output)
67
+ const ignoreGlobs = [...configuredIgnore, ...derivedIgnore].filter(Boolean)
68
+ // filter expanded files by ignore globs
69
+ const watchFiles = expanded.filter(f => !ignoreGlobs.some(g => minimatch(f, g, { dot: true })))
70
+
71
+ const watcher = chokidar.watch(watchFiles, {
72
+ ignored: /node_modules/,
68
73
  persistent: true,
69
74
  })
70
75
  watcher.on('change', path => {
@@ -110,16 +115,10 @@ program
110
115
 
111
116
  if (options.watch) {
112
117
  console.log('\nWatching for changes...')
113
- // Use the configured input patterns and respect extract.ignore if present
114
- const ignoredPatterns = [
115
- /node_modules/,
116
- ...(Array.isArray(config.extract?.ignore) ? config.extract.ignore : (config.extract?.ignore ? [config.extract?.ignore] : [])),
117
- ]
118
- const watchTargets = config.types?.input || []
119
- const watcher = chokidar.watch(watchTargets, {
120
- ignored: ignoredPatterns,
121
- persistent: true,
122
- })
118
+ const expandedTypes = await expandGlobs(config.types?.input || [])
119
+ const ignoredTypes = [...toArray(config.extract?.ignore)].filter(Boolean)
120
+ const watchTypes = expandedTypes.filter(f => !ignoredTypes.some(g => minimatch(f, g, { dot: true })))
121
+ const watcher = chokidar.watch(watchTypes, { persistent: true })
123
122
  watcher.on('change', path => {
124
123
  console.log(`\nFile changed: ${path}`)
125
124
  run()
@@ -178,13 +177,14 @@ program
178
177
  // Re-load the config to get the correct input paths for the watcher
179
178
  const config = await loadConfig()
180
179
  if (config?.extract?.input) {
181
- const ignoredPatterns = [
182
- /node_modules/,
183
- ...(Array.isArray(config.extract.ignore) ? config.extract.ignore : (config.extract.ignore ? [config.extract.ignore] : [])),
184
- ]
185
- const watchTargets = config.extract.input || []
186
- const watcher = chokidar.watch(watchTargets, {
187
- ignored: ignoredPatterns,
180
+ const expandedLint = await expandGlobs(config.extract.input)
181
+ const configuredIgnore2 = toArray(config.extract.ignore)
182
+ const derivedIgnore2 = deriveOutputIgnore(config.extract.output)
183
+ const ignoredLint = [...configuredIgnore2, ...derivedIgnore2].filter(Boolean)
184
+ const watchLint = expandedLint.filter(f => !ignoredLint.some(g => minimatch(f, g, { dot: true })))
185
+
186
+ const watcher = chokidar.watch(watchLint, {
187
+ ignored: /node_modules/,
188
188
  persistent: true,
189
189
  })
190
190
  watcher.on('change', path => {
@@ -224,3 +224,15 @@ program
224
224
  })
225
225
 
226
226
  program.parse(process.argv)
227
+
228
+ const toArray = (v: any) => Array.isArray(v) ? v : (v ? [v] : [])
229
+ const deriveOutputIgnore = (output?: string) => {
230
+ if (!output || typeof output !== 'string') return []
231
+ return [output.replace(/\{\{[^}]+\}\}/g, '*')]
232
+ }
233
+ // helper to expand one or many glob patterns
234
+ const expandGlobs = async (patterns: string | string[] = []) => {
235
+ const arr = toArray(patterns)
236
+ const sets = await Promise.all(arr.map(p => glob(p || '', { nodir: true })))
237
+ return Array.from(new Set(sets.flat()))
238
+ }