Skip to content

Commit

Permalink
chore: create cloud provider function to set provider property in app…
Browse files Browse the repository at this point in the history
…Info
  • Loading branch information
CyntiBinti committed Nov 7, 2023
1 parent fe22b5a commit 6b7a812
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/app-info/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ const processType =
(process.env.DYNO && normalizeHerokuProcessType(process.env.DYNO)) ||
null;

/**
* Sets the cloud provider type.
*
* @returns {string | null}
* Returns the cloud provider type (either aws or heroku).
*/
const cloudProvider = () => {
if (process.env.AWS_LAMBDA_FUNCTION_NAME) {
return 'aws';
}
if (process.env.HEROKU_RELEASE_CREATED_AT) {
return 'heroku';
}
return null;
};

module.exports = {
/**
* The application commit hash.
Expand Down Expand Up @@ -133,12 +149,7 @@ module.exports = {
* @readonly
* @type {string | null}
*/
cloudProvider:
(processType === process.env.AWS_LAMBDA_FUNCTION_NAME
? 'aws'
: Boolean(process.env.HEROKU_RELEASE_CREATED_AT)
? 'heroku'
: null) || null
cloudProvider: cloudProvider()
};

// @ts-ignore
Expand Down

0 comments on commit 6b7a812

Please sign in to comment.