Avoid overwriting native process env

This commit is contained in:
Nicholas Zuber 2020-01-26 19:53:03 -05:00
parent b066cf43c0
commit 4be1f2876c
7 changed files with 14 additions and 7 deletions

View File

@ -339,7 +339,8 @@ module.exports = {
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'process.localEnv': {
'NODE_ENV': JSON.stringify('local'),
'GIT_HASH': JSON.stringify(gitHash),
'OAUTH_TOKEN': JSON.stringify(localEnv.OAUTH_TOKEN)
}

View File

@ -424,7 +424,8 @@ module.exports = {
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'process.localEnv': {
'NODE_ENV': JSON.stringify('production'),
'GIT_HASH': JSON.stringify(gitHash)
}
}),

View File

@ -28,7 +28,7 @@ import FacebookLogo from '../../images/logos/facebook-logo.png';
import '../../styles/gradient.css';
import '../../styles/font.css';
const hash = process.env.GIT_HASH ? `#${process.env.GIT_HASH}` : '';
const hash = process.localEnv.GIT_HASH ? `#${process.localEnv.GIT_HASH}` : '';
const version = require('../../../package.json').version + hash;
const themeColor = '#457cff';

View File

@ -193,7 +193,7 @@ class NotificationsPage extends React.Component {
amplitude.getInstance().setUserProperties({
username: user.login,
full_name: user.name,
version: process.env.GIT_HASH ? process.env.GIT_HASH : 'unknown'
version: process.localEnv.GIT_HASH ? process.localEnv.GIT_HASH : 'unknown'
});
this.setState({user});
});

View File

@ -78,7 +78,7 @@ import {
} from './ui';
export const AnimatedNotificationRow = animated(NotificationRow);
const hash = process.env.GIT_HASH ? `#${process.env.GIT_HASH}` : '';
const hash = process.localEnv.GIT_HASH ? `#${process.localEnv.GIT_HASH}` : '';
const version = require('../../../../package.json').version + hash;
function PageItem ({children, onChange, ...props}) {

View File

@ -12,7 +12,7 @@ import '../../styles/font.css';
const themeColor = '#27B768';
const hash = process.env.GIT_HASH ? `#${process.env.GIT_HASH}` : '';
const hash = process.localEnv.GIT_HASH ? `#${process.localEnv.GIT_HASH}` : '';
const version = require('../../../package.json').version + hash;
export const forSmallScreens = rules => `

View File

@ -6,7 +6,12 @@ const {Provider, Consumer} = React.createContext();
class AuthProvider extends React.Component {
state = {
token: this.props.cookiesApi.getCookie(OAUTH_TOKEN_COOKIE) || process.env.OAUTH_TOKEN
token: (
this.props.cookiesApi.getCookie(OAUTH_TOKEN_COOKIE) ||
(process.localEnv.NODE_ENV === 'local'
? process.localEnv.OAUTH_TOKEN
: undefined)
)
}
setToken = token => {