Skip to content
GitLab
    • Explore Projects Groups Snippets
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
  • !3387
Something went wrong while fetching comments. Please try again.

fix #2223 - [feature] Implement dotenv-expand to accept variable expa…

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/moos/master into master 7 years ago
  • Overview 3
  • Commits 4
  • Pipelines 0
  • Changes 8

Created by: moos

…nsion in dot env files

Compare
  • master (base)

and
  • latest version
    cd1c4bf3
    4 commits, 2 years ago

8 files
+ 91
- 4

    Preferences

    File browser
    Compare changes
packages/re‎act-scripts‎
con‎fig‎
env‎.js‎ +7 -4
fixtures/k‎itchensink‎
integ‎ration‎
env.t‎est.js‎ +17 -0
s‎rc‎
featur‎es/env‎
ExpandEnvV‎ariables.js‎ +21 -0
ExpandEnvVari‎ables.test.js‎ +17 -0
App‎.js‎ +5 -0
.e‎nv‎ +4 -0
temp‎late‎
READ‎ME.md‎ +19 -0
packag‎e.json‎ +1 -0
packages/react-scripts/config/env.js
+ 7
- 4
  • View file @ cd1c4bf3

  • Edit in single-file editor

  • Open in Web IDE


@@ -35,13 +35,16 @@ var dotenvFiles = [
// Load environment variables from .env* files. Suppress warnings using silent
// if this file is missing. dotenv will never modify any environment variables
// that have already been set.
// that have already been set. Variable expansion is supported in .env files.
// https://github.com/motdotla/dotenv
// https://github.com/motdotla/dotenv-expand
dotenvFiles.forEach(dotenvFile => {
if (fs.existsSync(dotenvFile)) {
require('dotenv').config({
path: dotenvFile,
});
require('dotenv-expand')(
require('dotenv').config({
path: dotenvFile,
})
);
}
});
packages/react-scripts/fixtures/kitchensink/integration/env.test.js
+ 17
- 0
  • View file @ cd1c4bf3

  • Edit in single-file editor

  • Open in Web IDE


@@ -67,5 +67,22 @@ describe('Integration', () => {
doc.getElementById('feature-shell-env-variables').textContent
).to.equal('fromtheshell.');
});
it('expand .env variables', async () => {
const doc = await initDOM('expand-env-variables');
expect(doc.getElementById('feature-expand-env-1').textContent).to.equal(
'basic'
);
expect(doc.getElementById('feature-expand-env-2').textContent).to.equal(
'basic'
);
expect(doc.getElementById('feature-expand-env-3').textContent).to.equal(
'basic'
);
expect(
doc.getElementById('feature-expand-env-existing').textContent
).to.equal('fromtheshell');
});
});
});
packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.js 0 → 100644
+ 21
- 0
  • View file @ cd1c4bf3

  • Edit in single-file editor

  • Open in Web IDE

/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
export default () => (
<span>
<span id="feature-expand-env-1">{process.env.REACT_APP_BASIC}</span>
<span id="feature-expand-env-2">{process.env.REACT_APP_BASIC_EXPAND}</span>
<span id="feature-expand-env-3">
{process.env.REACT_APP_BASIC_EXPAND_SIMPLE}
</span>
<span id="feature-expand-env-existing">
{process.env.REACT_APP_EXPAND_EXISTING}
</span>
</span>
);
packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.test.js 0 → 100644
+ 17
- 0
  • View file @ cd1c4bf3

  • Edit in single-file editor

  • Open in Web IDE

/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import ExpandEnvVariables from './ExpandEnvVariables';
describe('expand .env variables', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<ExpandEnvVariables />, div);
});
});
packages/react-scripts/fixtures/kitchensink/src/App.js
+ 5
- 0
  • View file @ cd1c4bf3

  • Edit in single-file editor

  • Open in Web IDE


@@ -179,6 +179,11 @@ class App extends Component {
this.setFeature(f.default)
);
break;
case 'expand-env-variables':
import('./features/env/ExpandEnvVariables').then(f =>
this.setFeature(f.default)
);
break;
default:
throw new Error(`Missing feature "${feature}"`);
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/moos/master

Menu

Explore Projects Groups Snippets