diff --git a/README.md b/README.md index 625c52b..66ff306 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ -# Node.js mock for react-native-config +# react-native-config-node +[![Version][version-badge]][package] +[![semantic-release][semantic-release-badge]](https://github.com/semantic-release/semantic-release) +[![MIT License][license-badge]][license] + +Node.js mock for react-native-config A mock for [react-native-config](https://github.com/luggg/react-native-config), a module which offers an elegant way to inject environment-specific variables to [react-native](https://facebook.github.io/react-native/). @@ -53,27 +58,15 @@ NODE_ENV=staging mocha --compilers js:./test/lib/babel-register test/spec/*.js ## Jest -In order to use this mock with jest, you will need to add a plugin that renames imported module. -``` -npm i babel-plugin-import-rename --save-dev -``` - -Add the following to your .babelrc +Add the following plugin to your `babel.config.js` or `.babelrc` ``` { "presets": ["module:metro-react-native-babel-preset"], "env": { "test": { - "plugins": [ - [ - "import-rename", - { - "^react-native-config$": "react-native-config-node" - } - ] - ] + "plugins": ['react-native-config-node/transform'] } } } @@ -90,13 +83,13 @@ NODE_ENV=staging jest `react-native-config-node/transform` is a babel-plugin transforming the following code ```js -import Config from `react-native-config` +import Config from 'react-native-config' ``` into ```js -import Config from `react-native-config-node` +import Config from 'react-native-config-node' ``` `react-native-config-node` offers the same API as `react-native-config` using [dotenv](https://www.npmjs.com/package/dotenv). @@ -105,3 +98,9 @@ import Config from `react-native-config-node` ## License MIT + +[semantic-release-badge]:https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg +[license]: https://opensource.org/licenses/MIT +[version-badge]: https://img.shields.io/npm/v/react-native-config-node.svg +[package]: https://www.npmjs.com/package/react-native-config-node +[license-badge]: https://img.shields.io/npm/l/react-native-config-node.svg diff --git a/package.json b/package.json index 9ecb7ad..f7cc0d3 100644 --- a/package.json +++ b/package.json @@ -2,23 +2,27 @@ "name": "react-native-config-node", "version": "0.0.3", "description": "Mock for react-native-config in nodejs environment, used for testing", - "main": "index", "keywords": [ "env", "react-native", "12factor", "config" ], - "scripts": { - "test": "mocha test/transform.js && cd test && ./run-test.sh" - }, + "homepage": "https://github.com/CureApp/react-native-config-node", "repository": { "type": "git", "url": "https://github.com/CureApp/react-native-config-node.git" }, - "homepage": "https://github.com/CureApp/react-native-config-node", - "author": "CureApp, Inc.", "license": "MIT", + "author": "CureApp, Inc.", + "main": "index.js", + "files": [ + "index.js", + "transform.js" + ], + "scripts": { + "test": "mocha test/transform.js && cd test && ./run-test.sh" + }, "dependencies": { "dotenv": "^8.2.0" },