This repository was archived by the owner on May 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 5050 "babel-plugin-react-intl" : " ^5.1.12" ,
5151 "commander" : " 4.0.0-1" ,
5252 "fs-extra" : " ^8.1.0" ,
53+ "glob" : " ^7.0.0" ,
5354 "loader-utils" : " ^1.2.3" ,
5455 "lodash" : " ^4.17.15" ,
5556 "loud-rejection" : " ^2.1.0"
Original file line number Diff line number Diff line change 11import commander from 'commander' ;
22import loudRejection from 'loud-rejection' ;
33import extract , { ExtractCLIOptions } from './extract' ;
4+ import { sync as globSync } from 'glob' ;
45
56const KNOWN_COMMANDS = [ 'extract' ] ;
67
@@ -98,6 +99,15 @@ async function main(argv: string[]) {
9899 false
99100 )
100101 . action ( async ( files : readonly string [ ] , cmdObj : ExtractCLIOptions ) => {
102+ files = files . reduce (
103+ ( all : string [ ] , f ) =>
104+ all . concat (
105+ globSync ( f , {
106+ cwd : process . cwd ( ) ,
107+ } )
108+ ) ,
109+ [ ]
110+ ) ;
101111 await extract ( files , {
102112 outFile : cmdObj . outFile ,
103113 idInterpolationPattern :
Original file line number Diff line number Diff line change 11// Jest Snapshot v1, https://goo.gl/fbAQLP
22
3+ exports [` [glob] basic case: defineMessages -> stdout 1` ] = `
4+ Array [
5+ Object {
6+ " defaultMessage" : " Hello World!" ,
7+ " description" : " The default message" ,
8+ " id" : " foo.bar.baz" ,
9+ } ,
10+ Object {
11+ " defaultMessage" : " Hello Nurse!" ,
12+ " description" : " Another message" ,
13+ " id" : " foo.bar.biff" ,
14+ } ,
15+ Object {
16+ " defaultMessage" : " {count, plural, =0 {😭} one {# kitten} other {# kittens}}" ,
17+ " description" : " Counts kittens" ,
18+ " id" : " app.home.kittens" ,
19+ } ,
20+ Object {
21+ " defaultMessage" : " Some whitespace " ,
22+ " description" : " Whitespace" ,
23+ " id" : " trailing.ws" ,
24+ } ,
25+ Object {
26+ " defaultMessage" : " A quoted value ''{value}'" ,
27+ " description" : " Escaped apostrophe" ,
28+ " id" : " escaped.apostrophe" ,
29+ } ,
30+ Object {
31+ " defaultMessage" : " No ID" ,
32+ " description" : " no ID" ,
33+ " id" : " ae494" ,
34+ } ,
35+ ]
36+ ` ;
37+
338exports [` basic case: defineMessages -> directory 1` ] = `
439Array [
540 "actual.json",
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ test('basic case: defineMessages -> stdout', async () => {
2828 expect ( stderr ) . toBe ( '' ) ;
2929} , 10000 ) ;
3030
31+ test ( '[glob] basic case: defineMessages -> stdout' , async ( ) => {
32+ const { stdout, stderr} = await exec (
33+ `${ BIN_PATH } extract ${ path . join ( __dirname , 'defineMessages/*.js' ) } `
34+ ) ;
35+ expect ( JSON . parse ( stdout ) ) . toMatchSnapshot ( ) ;
36+ expect ( stderr ) . toBe ( '' ) ;
37+ } , 10000 ) ;
38+
3139test ( 'basic case: defineMessages -> directory' , async ( ) => {
3240 process . chdir ( __dirname ) ;
3341 const { stdout, stderr} = await exec (
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ const babel = require('@babel/core');
1818// Commander.js will call this.
1919jest . spyOn ( process , 'exit' ) . mockImplementation ( ( ( ) => null ) as any ) ;
2020
21+ jest . mock ( 'glob' , ( ) => ( {
22+ sync : ( p : string ) => [ p ] ,
23+ } ) ) ;
24+
2125beforeEach ( ( ) => {
2226 jest . clearAllMocks ( ) ;
2327} ) ;
You can’t perform that action at this time.
0 commit comments