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 3434 "clean" : " rimraf lib/" ,
3535 "test" : " cross-env NODE_ENV=test mocha --compilers js:babel-register" ,
3636 "build" : " babel src/ --out-dir lib/" ,
37+ "build:fixtures" : " babel-node ./scripts/build-fixtures.js" ,
3738 "preversion" : " npm run lint && npm run clean && npm run build" ,
3839 "prepublish" : " npm run clean && npm run build"
3940 },
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) {
2626 function Foo ( ) {
2727 _classCallCheck ( this , Foo ) ;
2828
29- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
29+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
3030 }
3131
3232 _createClass ( Foo , [ {
@@ -44,4 +44,3 @@ var Foo = function (_Component) {
4444} ( _react . Component ) ;
4545
4646exports . default = Foo ;
47-
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ var Foo = function (_Component) {
2626 function Foo ( ) {
2727 _classCallCheck ( this , Foo ) ;
2828
29- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
29+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
3030 }
3131
3232 _createClass ( Foo , [ {
@@ -44,4 +44,3 @@ var Foo = function (_Component) {
4444} ( _react . Component ) ;
4545
4646exports . default = Foo ;
47-
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ var Foo = function (_Component) {
3939 function Foo ( ) {
4040 _classCallCheck ( this , Foo ) ;
4141
42- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
42+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
4343 }
4444
4545 _createClass ( Foo , [ {
@@ -66,4 +66,3 @@ var Foo = function (_Component) {
6666} ( _react . Component ) ;
6767
6868exports . default = Foo ;
69-
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ var Foo = function (_Component) {
4343 function Foo ( ) {
4444 _classCallCheck ( this , Foo ) ;
4545
46- return _possibleConstructorReturn ( this , Object . getPrototypeOf ( Foo ) . apply ( this , arguments ) ) ;
46+ return _possibleConstructorReturn ( this , ( Foo . __proto__ || Object . getPrototypeOf ( Foo ) ) . apply ( this , arguments ) ) ;
4747 }
4848
4949 _createClass ( Foo , [ {
@@ -66,4 +66,3 @@ var Foo = function (_Component) {
6666} ( _react . Component ) ;
6767
6868exports . default = Foo ;
69-
You can’t perform that action at this time.
0 commit comments