Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"clean": "rimraf lib/",
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-register",
"build": "babel src/ --out-dir lib/",
"build:fixtures": "babel-node ./scripts/build-fixtures.js",
"preversion": "npm run lint && npm run clean && npm run build",
"prepublish": "npm run clean && npm run build"
},
Expand Down
37 changes: 37 additions & 0 deletions scripts/build-fixtures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as p from 'path';
import * as fs from 'fs';
import {transformFileSync} from 'babel-core';
import plugin from '../src/index';

const baseDir = p.resolve(`${__dirname}/../test/fixtures`);

const fixtures = [
'defineMessages',
'FormattedHTMLMessage',
'FormattedMessage',
['moduleSourceName', {
moduleSourceName: 'react-i18n',
}],
];

fixtures.forEach((fixture) => {
let name = fixture;
let options = {};
if (Array.isArray(fixture)) {
[name, options] = fixture;
}

let {code, metadata} = transformFileSync(`${baseDir}/${name}/actual.js`, {
plugins: [
[plugin, {
...options,
messagesDir: false,
}],
],
});

let messages = JSON.stringify(metadata['react-intl'].messages, null, 2);

fs.writeFileSync(`${baseDir}/${name}/expected.js`, `${code}\n`);
fs.writeFileSync(`${baseDir}/${name}/expected.json`, `${messages}\n`);
});
3 changes: 1 addition & 2 deletions test/fixtures/FormattedHTMLMessage/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Foo = function (_Component) {
function Foo() {
_classCallCheck(this, Foo);

return _possibleConstructorReturn(this, Object.getPrototypeOf(Foo).apply(this, arguments));
return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
}

_createClass(Foo, [{
Expand All @@ -44,4 +44,3 @@ var Foo = function (_Component) {
}(_react.Component);

exports.default = Foo;

3 changes: 1 addition & 2 deletions test/fixtures/FormattedMessage/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Foo = function (_Component) {
function Foo() {
_classCallCheck(this, Foo);

return _possibleConstructorReturn(this, Object.getPrototypeOf(Foo).apply(this, arguments));
return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
}

_createClass(Foo, [{
Expand All @@ -44,4 +44,3 @@ var Foo = function (_Component) {
}(_react.Component);

exports.default = Foo;

3 changes: 1 addition & 2 deletions test/fixtures/defineMessages/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var Foo = function (_Component) {
function Foo() {
_classCallCheck(this, Foo);

return _possibleConstructorReturn(this, Object.getPrototypeOf(Foo).apply(this, arguments));
return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
}

_createClass(Foo, [{
Expand All @@ -66,4 +66,3 @@ var Foo = function (_Component) {
}(_react.Component);

exports.default = Foo;

3 changes: 1 addition & 2 deletions test/fixtures/moduleSourceName/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var Foo = function (_Component) {
function Foo() {
_classCallCheck(this, Foo);

return _possibleConstructorReturn(this, Object.getPrototypeOf(Foo).apply(this, arguments));
return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
}

_createClass(Foo, [{
Expand All @@ -66,4 +66,3 @@ var Foo = function (_Component) {
}(_react.Component);

exports.default = Foo;