-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from sibelius/feat/cli
feat(cli): add ast-i18n cli to make life easier, see #45
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ npm-debug.log | |
dump.rdb | ||
bundle.js | ||
|
||
lib | ||
build | ||
dist | ||
coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../lib/cli.js').run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import yargs from 'yargs'; | ||
import shell from 'shelljs'; | ||
|
||
import { generateResources } from './generateResources'; | ||
|
||
type Argv = { | ||
src: string, | ||
keyMaxLength: number, | ||
} | ||
|
||
export const run = (argv: Argv) => { | ||
argv = yargs(argv || process.argv.slice(2)) | ||
.usage( | ||
'Extract all string inside JSXElement' | ||
) | ||
.default('src', process.cwd()) | ||
.describe( | ||
'src', | ||
'The source to collect strings' | ||
) | ||
.default('keyMaxLength', 40) | ||
.describe( | ||
'src', | ||
'The source to collect strings' | ||
) | ||
.argv; | ||
|
||
const jsFiles = shell.find(argv.src).filter(path => /\.(js|ts|tsx)$/.test(path)); | ||
|
||
generateResources(jsFiles, argv.keyMaxLength); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters