Compare commits

..

4 Commits

Author SHA1 Message Date
Kim Biesbjerg
8fd157802b update README 2019-09-16 20:42:10 +02:00
Kim Biesbjerg
1db4794ee9 bump version 2019-09-16 20:39:22 +02:00
Kim Biesbjerg
1eb1d0092d remove default boolean values 2019-09-16 20:39:02 +02:00
Kim Biesbjerg
4d3a3529b8 add typeRoots 2019-09-16 20:38:23 +02:00
4 changed files with 26 additions and 28 deletions

View File

@@ -78,7 +78,7 @@ _('Extract me');
`ngx-translate-extract ... -m _`
## Commandline arguments
```shell
```
Usage:
ngx-translate-extract [options]
@@ -89,23 +89,22 @@ Options:
can use path expansion, glob patterns and multiple
paths
[array] [default: current working path]
--patterns, -p Extract strings from the following file patterns
[array] [required] [default: current working path]
--patterns, -p Extract strings from the following file patterns
[array] [default: ["/**/*.html","/**/*.ts"]]
--output, -o Paths where you would like to save extracted
strings. You can use path expansion, glob patterns
and multiple paths [array] [required]
--format, -f Output format
--output, -o Paths where you would like to save extracted
strings. You can use path expansion, glob
patterns and multiple paths [array] [required]
--format, -f Output format
[string] [choices: "json", "namespaced-json", "pot"] [default: "json"]
--format-indentation, --fi Output format indentation [string] [default: " "]
--replace, -r Replace the contents of output file if it exists
(Merges by default) [boolean] [default: false]
--sort, -s Sort strings in alphabetical order when saving
[boolean] [default: false]
--clean, -c Remove obsolete strings when merging
[boolean] [default: false]
--format-indentation, --fi Output format indentation [string] [default: " "]
--replace, -r Replace the contents of output file if it exists
(Merges by default) [boolean]
--sort, -s Sort strings in alphabetical order when saving
[boolean]
--clean, -c Remove obsolete strings when merging [boolean]
--key-as-default-value, -k Use key as default value for translations
[boolean] [default: false]
[boolean]
--null-as-default-value, -n Use null as default value for translations
[boolean] [default: false]
Arguments key-as-default-value and null-as-default-value are mutually exclusive
[boolean]
```

View File

@@ -1,6 +1,6 @@
{
"name": "@biesbjerg/ngx-translate-extract",
"version": "4.1.0",
"version": "4.2.0",
"description": "Extract strings from projects using ngx-translate",
"main": "dist/index.js",
"typings": "dist/index.d.ts",

View File

@@ -25,12 +25,13 @@ export const cli = yargs
.option('input', {
alias: 'i',
describe: 'Paths you would like to extract strings from. You can use path expansion, glob patterns and multiple paths',
default: process.env.PWD,
default: [process.env.PWD],
type: 'array',
normalize: true
normalize: true,
required: true
})
.check(options => {
(options.input as unknown as string[]).forEach((dir: string) => {
options.input.forEach((dir: string) => {
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {
throw new Error(`The path you supplied was not found: '${dir}'`);
}
@@ -67,38 +68,33 @@ export const cli = yargs
.option('replace', {
alias: 'r',
describe: 'Replace the contents of output file if it exists (Merges by default)',
default: false,
type: 'boolean'
})
.option('sort', {
alias: 's',
describe: 'Sort strings in alphabetical order when saving',
default: false,
type: 'boolean'
})
.option('clean', {
alias: 'c',
describe: 'Remove obsolete strings when merging',
default: false,
type: 'boolean'
})
.option('key-as-default-value', {
alias: 'k',
describe: 'Use key as default value for translations',
default: false,
type: 'boolean'
})
.option('null-as-default-value', {
alias: 'n',
describe: 'Use null as default value for translations',
default: false,
type: 'boolean'
})
.conflicts('key-as-default-value', 'null-as-default-value')
.exitProcess(true)
.parse(process.argv);
const extractTask = new ExtractTask(cli.input as unknown as string[], cli.output, {
const extractTask = new ExtractTask(cli.input, cli.output, {
replace: cli.replace,
patterns: cli.patterns
});

View File

@@ -12,7 +12,10 @@
],
"module": "commonjs",
"outDir": "./dist/",
"sourceMap": true
"sourceMap": true,
"typeRoots" : [
"./node_modules/@types"
],
},
"include": [
"src/**/*.ts"