diff --git a/README.md b/README.md index 4aaa0129..9b47a366 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Multiple globbing patterns are supported to specify complex file selections. You **IMPORTANT NOTE**: If you pass the globs as CLI argument, they must be relative to where you run the command (aka relative to `process.cwd()`). If you pass the globs via the `input` option of the config file, they must be relative to the config file. -- **-c, --config **: Path to the config file (default: i18next-parser.config.js). +- **-c, --config **: Path to the config file (default: i18next-parser.config.{js,json,ts,yaml,yml}). - **-o, --output **: Path to the output directory (default: locales/$LOCALE/$NAMESPACE.json). - **-s, --silent**: Disable logging to stdout. - **--fail-on-warnings**: Exit with an exit code of 1 on warnings diff --git a/bin/cli.js b/bin/cli.js index 293f56a1..cee3573e 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -53,7 +53,7 @@ import i18nTransform from '../dist/transform.js' let config = {} try { - const result = await lilconfig(pkg.name, { + const lilcongifOptions = { searchPlaces: [ `${pkg.name}.config.js`, `${pkg.name}.config.json`, @@ -67,7 +67,15 @@ import i18nTransform from '../dist/transform.js' '.yaml': yamlConfigLoader, '.yml': yamlConfigLoader, }, - }).load(program.opts().config) + } + let result + if (program.opts().config) { + result = await lilconfig(pkg.name, lilcongifOptions).load( + program.opts().config + ) + } else { + result = await lilconfig(pkg.name, lilcongifOptions).search() + } config = result.config } catch (err) { if (err.code === 'MODULE_NOT_FOUND') { diff --git a/package.json b/package.json index c8bd7edb..76f794dd 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "scripts": { "coverage": "c8 --all --include='src/**/*[.js|.jsx|.ts|.tsx]' --reporter=lcov --reporter=text yarn test", "test": "mocha -r @babel/register -r @babel/polyfill --recursive test/*.test.js test/**/*.test.js", - "test:cli": "yarn -s build && ./bin/cli.js -c test/cli/i18next-parser.config.js && ./bin/cli.js -c test/cli/i18next-parser.config.ts && ./bin/cli.js -c test/cli/i18next-parser.config.yaml", + "test:cli": "yarn -s build && ./bin/cli.js '**/*.html' && ./bin/cli.js -c test/cli/i18next-parser.config.js && ./bin/cli.js -c test/cli/i18next-parser.config.ts && ./bin/cli.js -c test/cli/i18next-parser.config.yaml", "watch": "babel src -d dist -w", "prettify": "prettier --write \"{src,test}/**/*.js\"", "build": "babel src -d dist",