Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerhut committed Feb 24, 2018
0 parents commit d1bf26a
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80

[*.md]
indent_size = 4
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FOO=bar
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: standard
66 changes: 66 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

# Created by https://www.gitignore.io/api/node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# .env



# End of https://www.gitignore.io/api/node
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- stable
- lts/carbon
- lts/boron
after_success:
- npm install coveralls
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 George Chung

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# babel-plugin-transform-dotenv

[![Greenkeeper badge](https://badges.greenkeeper.io/Gerhut/babel-plugin-transform-dotenv.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/Gerhut/babel-plugin-transform-dotenv.svg?branch=master)](https://travis-ci.org/Gerhut/babel-plugin-transform-dotenv)
[![Coverage Status](https://coveralls.io/repos/github/Gerhut/babel-plugin-transform-dotenv/badge.svg?branch=master)](https://coveralls.io/github/Gerhut/babel-plugin-transform-dotenv?branch=master)
[![dependencies Status](https://david-dm.org/Gerhut/babel-plugin-transform-dotenv/status.svg)](https://david-dm.org/Gerhut/babel-plugin-transform-dotenv)
[![devDependencies Status](https://david-dm.org/Gerhut/babel-plugin-transform-dotenv/dev-status.svg)](https://david-dm.org/Gerhut/babel-plugin-transform-dotenv?type=dev)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

Transform `process.env.FIELD` into environment variables with dotenv.
1 change: 1 addition & 0 deletions __fixtures__/dotenv.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(process.env.FOO);
1 change: 1 addition & 0 deletions __fixtures__/dotenv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("bar");
1 change: 1 addition & 0 deletions __fixtures__/env.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(process.env.NODE_ENV);
1 change: 1 addition & 0 deletions __fixtures__/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("test");
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require('dotenv/config')

module.exports = function transformDotenvPlugin (babel) {
return {
name: 'transform-dotenv',
inherits: require('babel-plugin-transform-inline-environment-variables')
}
}
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "babel-plugin-transform-dotenv",
"version": "1.0.0",
"description": "Transform `process.env.FIELD` into environment variables with dotenv.",
"main": "index.js",
"scripts": {
"pretest": "eslint *.js",
"test": "jest",
"posttest": "jest --coverage"
},
"keywords": [
"babel-plugin"
],
"files": [
"index.js"
],
"author": "George Chung <Gerhut@GMail.com>",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-plugin-tester": "^5.0.0",
"eslint": "^4.18.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"jest": "^22.4.2"
},
"dependencies": {
"babel-plugin-transform-inline-environment-variables": "^0.3.0",
"dotenv": "^5.0.0"
}
}
18 changes: 18 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-env mocha */

const pluginTester = require('babel-plugin-tester')

pluginTester({
plugin: require('.'),
filename: __filename,
tests: {
'transform environment variables': {
fixture: '__fixtures__/env.babel.js',
outputFixture: '__fixtures__/env.js'
},
'transform dotenv variables': {
fixture: '__fixtures__/dotenv.babel.js',
outputFixture: '__fixtures__/dotenv.js'
}
}
})

0 comments on commit d1bf26a

Please sign in to comment.