{"_id":"shell-source","_rev":"8-37bba79be815a1594638bf1453a7c2d8","name":"shell-source","description":"Source environment variables from a shell script into a Node.js process.","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"shell-source","version":"1.0.0","description":"Source environment variables from a shell script into a Node.js process.","keywords":["source","shell","script","environment","variables","configuration","node","unix","posix"],"dependencies":{"concat-stream":"^1.4.7"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.2","tape":"^3.0.3","xtend":"^4.0.0"},"scripts":{"test":"node test","travis":"istanbul cover test/index.js --report lcovonly && cat coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"https://github.com/jessetane/shell-source"},"author":{"name":"Jesse Tane","email":"jesse.tane@gmail.com"},"gitHead":"94ec4150a25a5ddee94e0c2a2a05844952b4a022","bugs":{"url":"https://github.com/jessetane/shell-source/issues"},"homepage":"https://github.com/jessetane/shell-source","_id":"shell-source@1.0.0","_shasum":"98a75f1d4af640beb2742b66f9564b16f3524813","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jessetane","email":"jesse.tane@gmail.com"},"maintainers":[{"name":"jessetane","email":"jesse.tane@gmail.com"}],"dist":{"shasum":"98a75f1d4af640beb2742b66f9564b16f3524813","tarball":"https://registry.npmjs.org/shell-source/-/shell-source-1.0.0.tgz","integrity":"sha512-lJpzohmAlyhQsTCDvfRWPwdLmJB0e3/gpBl00jjeAfqPXL7tOEmkh53D6M883K9L/++rFYF2W82cwHTCZag7SA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAwhSEZ/eiyv6GTCLJTXfmEYpOI6rCSAhiPS9UlyXQUpAiEAiWO92O3gMNjseUcda1FRmhZYRpN5d2S5Kxk1oQpuPwI="}]},"directories":{}},"1.0.1":{"name":"shell-source","version":"1.0.1","description":"Source environment variables from a shell script into a Node.js process.","keywords":["source","shell","script","environment","variables","configuration","node","unix","posix"],"dependencies":{"concat-stream":"^1.4.7"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.2","tape":"^3.0.3","xtend":"^4.0.0"},"scripts":{"test":"node test","travis":"istanbul cover test/index.js --report lcovonly && cat coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"https://github.com/jessetane/shell-source"},"author":{"name":"Jesse Tane","email":"jesse.tane@gmail.com"},"gitHead":"ddcd45d47c278f75bbbd1bcf83abf937b99a2f65","bugs":{"url":"https://github.com/jessetane/shell-source/issues"},"homepage":"https://github.com/jessetane/shell-source","_id":"shell-source@1.0.1","_shasum":"263fb078c31717ff89a1942a27e4de18c32e269c","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jessetane","email":"jesse.tane@gmail.com"},"maintainers":[{"name":"jessetane","email":"jesse.tane@gmail.com"}],"dist":{"shasum":"263fb078c31717ff89a1942a27e4de18c32e269c","tarball":"https://registry.npmjs.org/shell-source/-/shell-source-1.0.1.tgz","integrity":"sha512-mpMwSoDS9FvoVxyb1MS9VDinFuGmdVBOGdYbqKvB+z4p7pNRQ7N05DRzUMYgfqOwTBiyhgiXYQwveyjWpMzJXA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCDY5Wmjov8EholPfncAL48X9eAsdgzqS1QcvZldKAZzgIhAOsHMbfBkCKTRIF/sA6ck6hxJ87FvlBJTuPq99N8SfDg"}]},"directories":{}},"1.1.0":{"name":"shell-source","version":"1.1.0","description":"Source environment variables from a shell script into a Node.js process.","keywords":["source","shell","script","environment","variables","configuration","node","unix","posix"],"dependencies":{"concat-stream":"^1.4.7","xtend":"^4.0.0"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.2","tape":"^3.0.3"},"scripts":{"test":"node test","travis":"istanbul cover test/index.js --report lcovonly && cat coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"git+https://github.com/jessetane/shell-source.git"},"author":{"name":"Jesse Tane","email":"jesse.tane@gmail.com"},"gitHead":"0e833f1ee135d2f9236931cd9233f5c19bd32cd6","bugs":{"url":"https://github.com/jessetane/shell-source/issues"},"homepage":"https://github.com/jessetane/shell-source#readme","_id":"shell-source@1.1.0","_shasum":"fb0bf6dfd66effce8a1169cf9fe2a73b02bdc39d","_from":".","_npmVersion":"2.8.3","_nodeVersion":"1.8.1","_npmUser":{"name":"jessetane","email":"jesse.tane@gmail.com"},"maintainers":[{"name":"jessetane","email":"jesse.tane@gmail.com"}],"dist":{"shasum":"fb0bf6dfd66effce8a1169cf9fe2a73b02bdc39d","tarball":"https://registry.npmjs.org/shell-source/-/shell-source-1.1.0.tgz","integrity":"sha512-0fv+XziPtSs2yqi48+K9PShh+kWlYxfcJxAAAO56oYepsZUNs+33sQfUX9iS/GCRBmrkuJ1D83b2oCupsCgn3g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGtvCvEd5ZJoGuWy9zpjX+DxL34oIMd2f3EdnWZdtn1DAiAGrFIR8Ms6jHp8oVmuktpj1D/Vd9FO35oY0TK0n/SNUw=="}]},"directories":{}}},"readme":"# shell-source\nSource environment variables from a shell script into a [Node.js](http://nodejs.org/) process.\n\n[![npm](http://img.shields.io/npm/v/shell-source.svg?style=flat-square)](http://www.npmjs.org/shell-source)\n[![tests](https://img.shields.io/travis/jessetane/shell-source.svg?style=flat-square&branch=master)](https://travis-ci.org/jessetane/shell-source)\n[![coverage](https://img.shields.io/coveralls/jessetane/shell-source.svg?style=flat-square&branch=master)](https://coveralls.io/r/jessetane/shell-source)\n\n#### Dragons:\n> Since sourcing a shell script allows it to execute arbitrary code, you should be 100% sure its contents are not malicious!\n\n## Why\nYou have some configuration data stored in a sourcable shell script, but need access to that data from a JavaScript program. You could try to parse the file as text, but that would only work if the script does not execute code or expand any variables.\n\n## How\nSpawns the process owner's default shell and executes a [POSIX](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#dot) compliant wrapper script that in turn [sources](http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x237.html) the file of your choosing. The wrapper then calls [`printenv`](http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html) which writes the child process' updated environment to stdout. The parent (Node.js) process then parses this output and updates `process.env`.\n\n## Example\nConsider the script below that needs to execute code before its variables can be evaluated:\n```bash\nexport SERVER_HOST=\"$(hostname)\"\nexport SERVER_PORT=\"$(grep -m1 '# HTTP Alternate' < /etc/services | sed 's/[^0-9]*\\(.*\\)\\/.*/\\1/')\"\nexport PATH=\"node_modules/.bin:$PATH\"\n```\n\nA Node.js process can use `shell-source` to emulate the behavior of `sh`'s `.` built-in, executing the script before absorbing any enviroment changes it effects:\n```javascript\nvar source = require('shell-source');\n\nsource(__dirname + '/env.sh', function(err) {\n  if (err) return console.error(err);\n\n  console.log(process.env.SERVER_HOST); // ::\n  console.log(process.env.SERVER_PORT); // 8080\n  console.log(process.env.PATH);        // node_modules/.bin:/usr/local/bin\n});\n```\n\n## Install\n```bash\n$ npm install shell-source\n```\n\n## Test\n```bash\n$ npm test\n```\n\n## Require\n#### `var source = require('shell-source');`\n\n## Use\n#### `source(filepath, [opts,] callback);`\n* `filepath` The full path to the shell script that should be sourced.\n* `opts` An options object which can contain:\n  * `source` A boolean. Defaults to `true`. If set to `false`, the callback can receive the evironment object as its second argument and `process.env` will be left unmolested.  \n  * `wrapper` Use your own wrapper script. [`source.sh`](https://github.com/jessetane/shell-source/blob/master/source.sh) is used by default.\n  * `reserved` An object to merge with the default [blacklist](https://github.com/jessetane/shell-source/blob/master/index.js#L5) where `SHLVL` and `_` are already set to `true`.\n* `callback` A callback with signature:\n```javascript\nfunction(err, environment) {\n  // console.log(err, environment);\n}\n```\n\n## Notes\nObviously it would be nice if this could be done synchronously. However, until something like [this](http://strongloop.com/strongblog/whats-new-in-node-js-v0-12-execsync-a-synchronous-api-for-child-processes) lands on stable, I'm not sure if there is a sane way to accomplish it. If there is, please let me know.\n\n## Releases\nThe latest stable release is published to [npm](https://www.npmjs.org/package/shell-source). Tarballs for each release can be found [here](https://github.com/jessetane/shell-source/releases).\n* [1.1.0](https://github.com/jessetane/shell-source/releases/tag/1.1.0)\n * xtend is not a dev dependency (thanks @sparkleholic)\n* [1.0.x](https://github.com/jessetane/shell-source/releases/tag/1.0.1)\n * First release.\n\n## License\nCopyright © 2014 Jesse Tane <jesse.tane@gmail.com>\n\nThis work is free. You can redistribute it and/or modify it under the\nterms of the [WTFPL](http://www.wtfpl.net/txt/copying).\n\nNo Warranty. The Software is provided \"as is\" without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.\n","maintainers":[{"name":"jessetane","email":"jesse.tane@gmail.com"}],"time":{"modified":"2022-06-26T18:47:27.127Z","created":"2014-11-29T19:20:04.819Z","1.0.0":"2014-11-29T19:20:04.819Z","1.0.1":"2014-11-29T19:28:18.158Z","1.1.0":"2015-05-06T13:11:10.745Z"},"homepage":"https://github.com/jessetane/shell-source#readme","keywords":["source","shell","script","environment","variables","configuration","node","unix","posix"],"repository":{"type":"git","url":"git+https://github.com/jessetane/shell-source.git"},"author":{"name":"Jesse Tane","email":"jesse.tane@gmail.com"},"bugs":{"url":"https://github.com/jessetane/shell-source/issues"},"readmeFilename":"readme.md","users":{"skwny":true}}