This repository was archived by the owner on Jun 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +42
-8
lines changed Expand file tree Collapse file tree 6 files changed +42
-8
lines changed Original file line number Diff line number Diff line change 34
34
"clean" : " rimraf lib/" ,
35
35
"test" : " cross-env NODE_ENV=test mocha --compilers js:babel-register" ,
36
36
"build" : " babel src/ --out-dir lib/" ,
37
+ "build:fixtures" : " babel-node ./scripts/build-fixtures.js" ,
37
38
"preversion" : " npm run lint && npm run clean && npm run build" ,
38
39
"prepublish" : " npm run clean && npm run build"
39
40
},
Original file line number Diff line number Diff line change
1
+ import * as p from 'path' ;
2
+ import * as fs from 'fs' ;
3
+ import { transformFileSync } from 'babel-core' ;
4
+ import plugin from '../src/index' ;
5
+
6
+ const baseDir = p . resolve ( `${ __dirname } /../test/fixtures` ) ;
7
+
8
+ const fixtures = [
9
+ 'defineMessages' ,
10
+ 'FormattedHTMLMessage' ,
11
+ 'FormattedMessage' ,
12
+ [ 'moduleSourceName' , {
13
+ moduleSourceName : 'react-i18n' ,
14
+ } ] ,
15
+ ] ;
16
+
17
+ fixtures . forEach ( ( fixture ) => {
18
+ let name = fixture ;
19
+ let options = { } ;
20
+ if ( Array . isArray ( fixture ) ) {
21
+ [ name , options ] = fixture ;
22
+ }
23
+
24
+ let { code, metadata} = transformFileSync ( `${ baseDir } /${ name } /actual.js` , {
25
+ plugins : [
26
+ [ plugin , {
27
+ ...options ,
28
+ messagesDir : false ,
29
+ } ] ,
30
+ ] ,
31
+ } ) ;
32
+
33
+ let messages = JSON . stringify ( metadata [ 'react-intl' ] . messages , null , 2 ) ;
34
+
35
+ fs . writeFileSync ( `${ baseDir } /${ name } /expected.js` , `${ code } \n` ) ;
36
+ fs . writeFileSync ( `${ baseDir } /${ name } /expected.json` , `${ messages } \n` ) ;
37
+ } ) ;
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ var Foo = function (_Component) {
26
26
function Foo ( ) {
27
27
_classCallCheck ( this , Foo ) ;
28
28
29
- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
29
+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
30
30
}
31
31
32
32
_createClass ( Foo , [ {
@@ -44,4 +44,3 @@ var Foo = function (_Component) {
44
44
} ( _react . Component ) ;
45
45
46
46
exports . default = Foo ;
47
-
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ var Foo = function (_Component) {
26
26
function Foo ( ) {
27
27
_classCallCheck ( this , Foo ) ;
28
28
29
- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
29
+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
30
30
}
31
31
32
32
_createClass ( Foo , [ {
@@ -44,4 +44,3 @@ var Foo = function (_Component) {
44
44
} ( _react . Component ) ;
45
45
46
46
exports . default = Foo ;
47
-
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ var Foo = function (_Component) {
39
39
function Foo ( ) {
40
40
_classCallCheck ( this , Foo ) ;
41
41
42
- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
42
+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
43
43
}
44
44
45
45
_createClass ( Foo , [ {
@@ -66,4 +66,3 @@ var Foo = function (_Component) {
66
66
} ( _react . Component ) ;
67
67
68
68
exports . default = Foo ;
69
-
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ var Foo = function (_Component) {
43
43
function Foo ( ) {
44
44
_classCallCheck ( this , Foo ) ;
45
45
46
- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
46
+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
47
47
}
48
48
49
49
_createClass ( Foo , [ {
@@ -66,4 +66,3 @@ var Foo = function (_Component) {
66
66
} ( _react . Component ) ;
67
67
68
68
exports . default = Foo ;
69
-
You can’t perform that action at this time.
0 commit comments