diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:43:05 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 22:18:30 +0800 |
| commit | 89e95b3f143682ed9a006991bacf45c9dcba4818 (patch) | |
| tree | 4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/envify | |
| parent | aa7f0199255277949790b41c56e8ec97dd4f0da4 (diff) | |
| download | xmake-docs-vuepress.tar.gz xmake-docs-vuepress.zip | |
remove node_modulesvuepress
Diffstat (limited to 'node_modules/envify')
| l--------- | node_modules/envify/.bin/envify | 1 | ||||
| -rw-r--r-- | node_modules/envify/.npmignore | 2 | ||||
| -rw-r--r-- | node_modules/envify/README.md | 145 | ||||
| -rwxr-xr-x | node_modules/envify/bin/envify | 17 | ||||
| -rw-r--r-- | node_modules/envify/custom.js | 91 | ||||
| -rw-r--r-- | node_modules/envify/index.js | 1 | ||||
| l--------- | node_modules/envify/node_modules/.bin/esparse | 1 | ||||
| l--------- | node_modules/envify/node_modules/.bin/esvalidate | 1 | ||||
| -rw-r--r-- | node_modules/envify/package.json | 35 |
9 files changed, 0 insertions, 294 deletions
diff --git a/node_modules/envify/.bin/envify b/node_modules/envify/.bin/envify deleted file mode 120000 index 6045a55e..00000000 --- a/node_modules/envify/.bin/envify +++ /dev/null @@ -1 +0,0 @@ -../bin/envify
\ No newline at end of file diff --git a/node_modules/envify/.npmignore b/node_modules/envify/.npmignore deleted file mode 100644 index 5acd1cf2..00000000 --- a/node_modules/envify/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -test.js -.travis.yml diff --git a/node_modules/envify/README.md b/node_modules/envify/README.md deleted file mode 100644 index 37f2c650..00000000 --- a/node_modules/envify/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# envify [](http://travis-ci.org/hughsk/envify) [](http://github.com/hughsk/stability-badges) # - -Selectively replace Node-style environment variables with plain strings. -Available as a standalone CLI tool and a -[Browserify](http://browserify.org) v2 transform. - -Works best in combination with [uglifyify](http://github.com/hughsk/uglifyify). - -## Installation ## - -If you're using the module with Browserify: - -``` bash -npm install envify browserify -``` - -Or, for the CLI: - -``` bash -sudo npm install -g envify -``` - -## Usage ## - -envify will replace your environment variable checks with ordinary strings - -only the variables you use will be included, so you don't have to worry about, -say, `AWS_SECRET_KEY` leaking through either. Take this example script: - -``` javascript -if (process.env.NODE_ENV === "development") { - console.log('development only') -} -``` - -After running it through envify with `NODE_ENV` set to `production`, you'll -get this: - -``` javascript -if ("production" === "development") { - console.log('development only') -} -``` - -By running this through a good minifier (e.g. -[UglifyJS2](https://github.com/mishoo/UglifyJS)), the above code would be -stripped out completely. - -However, if you bundled the same script with `NODE_ENV` set to `development`: - -``` javascript -if ("development" === "development") { - console.log('development only') -} -``` - -The `if` statement will evaluate to `true`, so the code won't be removed. - -## CLI Usage ## - -With browserify: - -``` bash -browserify index.js -t envify > bundle.js -``` - -Or standalone: - -``` bash -envify index.js > bundle.js -``` - -You can also specify additional custom environment variables using -browserify's [subarg](http://github.com/substack/subarg) syntax, which is -available in versions 3.25.0 and above: - -``` bash -browserify index.js -t [ envify --NODE_ENV development ] > bundle.js -browserify index.js -t [ envify --NODE_ENV production ] > bundle.js -``` - -## Module Usage ## - -**require('envify')** - -Returns a transform stream that updates based on the Node process' -`process.env` object. - -**require('envify/custom')([environment])** - -If you want to stay away from your environment variables, you can supply -your own object to use in its place: - -``` javascript -var browserify = require('browserify') - , envify = require('envify/custom') - , fs = require('fs') - -var b = browserify('main.js') - , output = fs.createWriteStream('bundle.js') - -b.transform(envify({ - NODE_ENV: 'development' -})) -b.bundle().pipe(output) -``` - -## Purging `process.env` ## - -By default, environment variables that are not defined will be left untouched. -This is because in some cases, you might want to run an envify transform over -your source more than once, and removing these values would make that -impossible. - -However, if any references to `process.env` are remaining after transforming -your source with envify, browserify will automatically insert its shim for -Node's process object, which will increase the size of your bundle. This weighs -in at around 2KB, so if you're trying to be conservative with your bundle size -you can "purge" these remaining variables such that any missing ones are simply -replaced with undefined. - -To do so through the command-line, simply use the subarg syntax and include -`purge` after `envify`, e.g.: - -``` bash -browserify index.js -t [ envify purge --NODE_ENV development ] -``` - -Or if you're using the module API, you can pass `_: "purge"` into your -arguments like so: - -``` javascript -b.transform(envify({ - _: 'purge' - , NODE_ENV: 'development' -})) -``` - -## Contributors ## - -* [hughsk](http://github.com/hughsk) -* [benjamn](http://github.com/benjamn) -* [zag2art](http://github.com/zag2art) -* [bjoerge](http://github.com/bjoerge) -* [andreypopp](http://github.com/andreypopp) -* [jupl](http://github.com/jupl) diff --git a/node_modules/envify/bin/envify b/node_modules/envify/bin/envify deleted file mode 100755 index 756e28b1..00000000 --- a/node_modules/envify/bin/envify +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env node - -var envify = require('../') - , fs = require('fs') - -if (process.argv[2]) { - fs.createReadStream(process.argv[2], { encoding: 'utf8' }) - .pipe(envify(process.argv[2])) - .pipe(process.stdout) -} else { - process.stdin.resume() - process.stdin - .pipe(envify(__filename)) - .pipe(process.stdout) -} - - diff --git a/node_modules/envify/custom.js b/node_modules/envify/custom.js deleted file mode 100644 index 981ee834..00000000 --- a/node_modules/envify/custom.js +++ /dev/null @@ -1,91 +0,0 @@ -var esprima = require('esprima') - , through = require('through') - -var processEnvPattern = /\bprocess\.env\b/ - -module.exports = function(rootEnv) { - rootEnv = rootEnv || process.env || {} - - return function envify(file, argv) { - if (/\.json$/.test(file)) return through() - - var Syntax = esprima.Syntax - var buffer = [] - argv = argv || {} - - return through(write, flush) - - function write(data) { - buffer.push(data) - } - - function transform(source, envs) { - var args = [].concat(envs[0]._ || []).concat(envs[1]._ || []) - var purge = args.indexOf('purge') !== -1 - var replacements = [] - - function match(node) { - return ( - node.type === Syntax.MemberExpression - && node.object.type === Syntax.MemberExpression - && node.object.computed === false - && node.object.object.type === Syntax.Identifier - && node.object.object.name === 'process' - && node.object.property.type === Syntax.Identifier - && node.object.property.name === 'env' - && (node.computed ? node.property.type === Syntax.Literal : node.property.type === Syntax.Identifier) - ) - } - - esprima.parse(source, { tolerant: true }, function(node, meta) { - if (match(node)) { - var key = node.property.name || node.property.value - for (var i = 0; i < envs.length; i++) { - var value = envs[i][key] - if (value !== undefined) { - replacements.push({ node: node, meta: meta, value: JSON.stringify(value) }) - return - } - } - if (purge) { - replacements.push({ node: node, meta: meta, value: undefined }) - } - } else if (node.type === Syntax.AssignmentExpression) { - for (var i = 0; i < replacements.length; ++i) { - if (replacements[i].node === node.left) { - replacements.splice(i, 1) - } - } - } - }) - - var result = source - if (replacements.length > 0) { - replacements.sort(function (a, b) { - return b.meta.start.offset - a.meta.start.offset - }) - for (var i = 0; i < replacements.length; i++) { - var r = replacements[i] - result = result.slice(0, r.meta.start.offset) + r.value + result.slice(r.meta.end.offset) - } - } - - return result - } - - function flush() { - var source = buffer.join('') - - if (processEnvPattern.test(source)) { - try { - source = transform(source, [argv, rootEnv]) - } catch(err) { - return this.emit('error', err) - } - } - - this.queue(source) - this.queue(null) - } - } -} diff --git a/node_modules/envify/index.js b/node_modules/envify/index.js deleted file mode 100644 index 20798e9d..00000000 --- a/node_modules/envify/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./custom')(process.env) diff --git a/node_modules/envify/node_modules/.bin/esparse b/node_modules/envify/node_modules/.bin/esparse deleted file mode 120000 index d3e4b572..00000000 --- a/node_modules/envify/node_modules/.bin/esparse +++ /dev/null @@ -1 +0,0 @@ -../../../esprima/bin/esparse.js
\ No newline at end of file diff --git a/node_modules/envify/node_modules/.bin/esvalidate b/node_modules/envify/node_modules/.bin/esvalidate deleted file mode 120000 index f8ef4b99..00000000 --- a/node_modules/envify/node_modules/.bin/esvalidate +++ /dev/null @@ -1 +0,0 @@ -../../../esprima/bin/esvalidate.js
\ No newline at end of file diff --git a/node_modules/envify/package.json b/node_modules/envify/package.json deleted file mode 100644 index 28e3b2d6..00000000 --- a/node_modules/envify/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "envify", - "version": "4.1.0", - "description": "Selectively replace Node-style environment variables with plain strings.", - "main": "index.js", - "scripts": { - "test": "node test.js | tap-spec" - }, - "bin": { - "envify": "bin/envify" - }, - "repository": { - "type": "git", - "url": "git://github.com/hughsk/envify.git" - }, - "author": "Hugh Kennedy <hughskennedy@gmail.com> (http://hughskennedy.com/)", - "license": "MIT", - "devDependencies": { - "tap-spec": "^4.1.1", - "tape": "^4.6.0" - }, - "dependencies": { - "esprima": "^4.0.0", - "through": "~2.3.4" - }, - "keywords": [ - "environment", - "variables", - "browserify", - "browserify-transform", - "transform", - "source", - "configuration" - ] -} |
