You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0 KiB

4 years ago
  1. # loose-envify
  2. [![Build Status](https://travis-ci.org/zertosh/loose-envify.svg?branch=master)](https://travis-ci.org/zertosh/loose-envify)
  3. Fast (and loose) selective `process.env` replacer using [js-tokens](https://github.com/lydell/js-tokens) instead of an AST. Works just like [envify](https://github.com/hughsk/envify) but much faster.
  4. ## Gotchas
  5. * Doesn't handle broken syntax.
  6. * Doesn't look inside embedded expressions in template strings.
  7. - **this won't work:**
  8. ```js
  9. console.log(`the current env is ${process.env.NODE_ENV}`);
  10. ```
  11. * Doesn't replace oddly-spaced or oddly-commented expressions.
  12. - **this won't work:**
  13. ```js
  14. console.log(process./*won't*/env./*work*/NODE_ENV);
  15. ```
  16. ## Usage/Options
  17. loose-envify has the exact same interface as [envify](https://github.com/hughsk/envify), including the CLI.
  18. ## Benchmark
  19. ```
  20. envify:
  21. $ for i in {1..5}; do node bench/bench.js 'envify'; done
  22. 708ms
  23. 727ms
  24. 791ms
  25. 719ms
  26. 720ms
  27. loose-envify:
  28. $ for i in {1..5}; do node bench/bench.js '../'; done
  29. 51ms
  30. 52ms
  31. 52ms
  32. 52ms
  33. 52ms
  34. ```