-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mrsteele/feature/init
feat: Initial commit.
- Loading branch information
Showing
10 changed files
with
246 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
sudo: false | ||
language: node_js | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false | ||
node_js: | ||
- '5' | ||
- '4' | ||
- iojs-v3 | ||
- iojs-v2 | ||
- '0.12' | ||
before_install: | ||
- npm i -g npm@^2.0.0 | ||
before_script: | ||
- npm prune | ||
script: | ||
- npm run travis | ||
after_success: | ||
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all' | ||
- python travis_after_all.py | ||
- export $(cat .to_export_back) &> /dev/null | ||
- npm run semantic-release | ||
branches: | ||
except: | ||
- /^v\d+\.\d+\.\d+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# dotenv-webpack | ||
|
||
A simple webpack plugin to support dotenv. | ||
|
||
### Status | ||
|
||
[![npm](https://img.shields.io/npm/v/dotenv-webpack.svg?maxAge=0&style=flat)](https://www.npmjs.com/package/dotenv-webpack) | ||
[![Travis](https://travis-ci.org/mrsteele/dotenv-webpack.svg?branch=master)](https://travis-ci.org/mrsteele/dotenv-webpack) | ||
[![Coverage Status](https://coveralls.io/repos/github/mrsteele/dotenv-webpack/badge.svg?branch=master)](https://coveralls.io/github/mrsteele/dotenv-webpack?branch=master) | ||
[![Dependency Status](https://david-dm.org/mrsteele/dotenv-webpack.svg)](https://david-dm.org/mrsteele/dotenv-webpack) | ||
[![devDependency Status](https://david-dm.org/mrsteele/dotenv-webpack/dev-status.svg)](https://david-dm.org/mrsteele/dotenv-webpack#info=devDependencies) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) | ||
[![npm](https://img.shields.io/npm/l/dotenv-webpack.svg?maxAge=0&style=flat)](https://raw.githubusercontent.com/mrsteele/dotenv-webpack/master/LICENSE) | ||
[![pull requests](https://img.shields.io/badge/pull%20requests-accepting-brightgreen.svg?style=flat)](https://github.com/mrsteele/dotenv-webpack/fork) | ||
|
||
### Installation | ||
|
||
Include the package locally in your repository. | ||
|
||
`npm install dotenv-webpack --save` | ||
|
||
### Basic Usage | ||
|
||
The plugin can be installed with little-to-no configuration needed. | ||
|
||
```javascript | ||
// webpack.config.js | ||
const Dotenv = require('dotenv-webpack'); | ||
|
||
module.exports = { | ||
... | ||
plugins: [ | ||
new Dotenv({ | ||
path: './.env' // can be ommitted as this is the default | ||
}) | ||
] | ||
... | ||
}; | ||
``` | ||
|
||
### LICENSE | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var plugin = require('./dist').default | ||
|
||
module.exports = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"tags": { | ||
"allowUnknownTags": true | ||
}, | ||
"source": { | ||
"include": [ | ||
"./src/" | ||
], | ||
"excludePattern": "(^|\\/|\\\\)_" | ||
}, | ||
"opts": { | ||
"encoding": "utf8", | ||
"recurse": true, | ||
"private": false, | ||
"destination": "./docs", | ||
"readme": "./README.md", | ||
"package": "./package.json", | ||
"tutorials": "./tutorials" | ||
}, | ||
"plugins": [ | ||
"plugins/markdown" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
let plugin | ||
try { | ||
plugin = require('./dist').default | ||
} catch (err) { | ||
if (err.code === 'MODULE_NOT_FOUND') { | ||
require('babel-register') | ||
plugin = require('./src').default | ||
} else { | ||
console.log(err) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
module.exports = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"name": "dotenv-webpack", | ||
"description": "A simple webpack plugin to support dotenv.", | ||
"version": "0.0.0-semantically-released", | ||
"main": "index.js", | ||
"scripts": { | ||
"precommit": "npm run standard && npm run build && npm run cover", | ||
"commit": "git-cz", | ||
"standard": "standard", | ||
"predoc": "rimraf docs", | ||
"doc": "jsdoc -c doc.json", | ||
"cover": "nyc npm t && npm run coverage-report", | ||
"coverage-check": "nyc check-coverage --branches 100 --statements 100 --functions 100 --lines 100", | ||
"coverage-report": "nyc report --reporter=lcov", | ||
"test": "_mocha --compilers js:babel-register", | ||
"prebuild": "rimraf dist", | ||
"build": "babel --copy-files --out-dir dist src", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"travis": "npm run precommit", | ||
"travis2": "npm run precommit && npm run coveralls && npm run coverage-check", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mrsteele/dotenv-webpack.git" | ||
}, | ||
"keywords": [ | ||
"dotenv", | ||
"webpack", | ||
"plugin" | ||
], | ||
"author": "Matt Steele <matt@omnionline.us> (http://omnionline.us/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mrsteele/dotenv-webpack/issues" | ||
}, | ||
"homepage": "https://github.com/mrsteele/dotenv-webpack#readme", | ||
"dependencies": { | ||
"dotenv-safe": "^2.3.1", | ||
"webpack": "^1.13.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.10.1", | ||
"babel-eslint": "^6.1.0", | ||
"babel-plugin-transform-object-assign": "^6.8.0", | ||
"babel-preset-es2015": "^6.9.0", | ||
"babel-register": "^6.9.0", | ||
"chai": "^3.5.0", | ||
"chai-subset": "^1.2.2", | ||
"commitizen": "^2.8.2", | ||
"coveralls": "^2.11.9", | ||
"cz-conventional-changelog": "^1.1.6", | ||
"jsdoc": "^3.4.0", | ||
"mocha": "^2.5.3", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"nyc": "^6.6.1", | ||
"rimraf": "^2.5.2", | ||
"semantic-release": "^4.3.5", | ||
"standard": "^7.1.2" | ||
}, | ||
"files": [ | ||
"dist", | ||
"browser.js", | ||
"README.md" | ||
], | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
}, | ||
"standard": { | ||
"parser": "babel-eslint" | ||
}, | ||
"browser": "./browser.js", | ||
"babel": { | ||
"presets": [ | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"transform-object-assign" | ||
] | ||
}, | ||
"nyc": { | ||
"include": [ | ||
"src/**/*.js" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import dotenv from 'dotenv-safe' | ||
import fs from 'fs' | ||
import { DefinePlugin } from 'webpack' | ||
|
||
class Dotenv { | ||
constructor (options) { | ||
options = options || {} | ||
if (!options.path) options.path = './.env' | ||
|
||
dotenv.config(options) | ||
this.env = {} | ||
|
||
try { | ||
this.env = dotenv.parse(fs.readFileSync(options.path)) | ||
} catch (err) {} | ||
} | ||
|
||
apply (compiler) { | ||
const plugin = Object.keys(this.example).reduce((definitions, key) => { | ||
const value = process.env[key] || this.env[key] | ||
definitions[`process.env.${key}`] = JSON.stringify(value) | ||
return definitions | ||
}, {}) | ||
|
||
compiler.apply(new DefinePlugin(plugin)) | ||
} | ||
} | ||
|
||
export default Dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* global describe, it */ | ||
|
||
// Tests suite | ||
import chai from 'chai' | ||
chai.should() | ||
|
||
describe('The tests', () => { | ||
it('Should be able to run tests.', () => { | ||
true.should.be.true | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--require chai | ||
--reporter spec | ||
--ui bdd | ||
--recursive |