Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !2506

Convert any env var string containing only digits to a number

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/AJamesPhillips/env_var_numbers into master Jun 09, 2017
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: AJamesPhillips

This would be a breaking change and also prevents separation of obtaining env vars from parsing env vars. Having said that I find this very convenient to use in my own project and am interested to hear what others think about it. For example making boolean flags is trivial: REACT_APP_SEND_EMAIL=0 then in code if (process.env.REACT_APP_SEND_EMAIL) { ... } else { // not sending email } and validations used in front and back end code have the same value if (password.length < process.env.REACT_APP_MIN_PASSWORD_LENGTH) { ... }.

Will add docs if there's interest in this otherwise will close and leave for others to find and use as they wish.

Note this correctly handles non numbers such as random strings 47cbe9fb2a5c, ip addresses 234.234.234.234, and octal / file permissions / non numbers 0644 or 123 123 by leaving them as strings.

Additionally if someone is already using parseInt(ENV_VAR) this remains unchanged however ENV_VAR === "1" would break hence the breaking change statement.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/AJamesPhillips/env_var_numbers