Skip to content

Commit

Permalink
Update test for mjs config
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Novack committed Dec 16, 2022
1 parent 84f516e commit bc9c6c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>**: Path to the config file (default: i18next-parser.config.{js,json,ts,yaml,yml}).
- **-c, --config <path>**: Path to the config file (default: i18next-parser.config.{js,mjs,json,ts,yaml,yml}).
- **-o, --output <path>**: 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
Expand Down Expand Up @@ -93,17 +93,17 @@ npm install --save-dev i18next-parser

```javascript
import Funnel from 'broccoli-funnel'
import { broccoli as i18nextParser} from 'i18next-parser'
import { broccoli as i18nextParser } from 'i18next-parser'

const appRoot = 'broccoli'

let i18n = new Funnel(appRoot, {
files: ['handlebars.hbs', 'javascript.js'],
annotation: 'i18next-parser'
annotation: 'i18next-parser',
})

i18n = new i18nextParser([i18n], {
output: 'broccoli/locales/$LOCALE/$NAMESPACE.json'
output: 'broccoli/locales/$LOCALE/$NAMESPACE.json',
})

export default i18n
Expand Down
2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import i18nTransform from '../dist/transform.js'
.version(pkg.version)
.option(
'-c, --config <path>',
'Path to the config file (default: i18next-parser.config.{js,json,ts,yaml,yml})'
'Path to the config file (default: i18next-parser.config.{js,mjs,json,ts,yaml,yml})'
)
.option(
'-o, --output <path>',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 '**/*.html' -o 'test/manual/$LOCALE/$NAMESPACE.json' && ./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' -o 'test/manual/$LOCALE/$NAMESPACE.json' && ./bin/cli.js -c test/cli/i18next-parser.config.js && ./bin/cli.js -c test/cli/i18next-parser.config.mjs && ./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",
Expand Down
10 changes: 10 additions & 0 deletions test/cli/i18next-parser.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import path from 'path'
import { fileURLToPath } from 'url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

export default {
input: ['**/*.html'],
output: path.resolve(__dirname, 'locales/$LOCALE/$NAMESPACE.json'),
sort: true,
}

0 comments on commit bc9c6c4

Please sign in to comment.