Skip to content

Commit

Permalink
Improve optional modules loading (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
clementbiron authored Feb 15, 2024
2 parents 78c8132 + 8cc8b29 commit 584b488
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## Unreleased [minor]

_Full changeset and discussions: [#1052](https://github.com/OpenTermsArchive/engine/pull/1052)._

> Development of this release was supported by the [French Ministry for Foreign Affairs](https://www.diplomatie.gouv.fr/fr/politique-etrangere-de-la-france/diplomatie-numerique/) through its ministerial [State Startups incubator](https://beta.gouv.fr/startups/open-terms-archive.html) under the aegis of the Ambassador for Digital Affairs.
### Changed

- **Breaking:** Base the loading of the Notifier module on the presence of required configuration, not on the environment; only define the `SENDINBLUE_API_KEY` environment variable if you want the Notifier to be loaded, avoid relying on `NODE_ENV=production`

## 0.35.0 - 2024-02-14

Expand Down
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export default async function track({ services, types, extractOnly, schedule })
return;
}

if (process.env.NODE_ENV === 'production') {
if (process.env.SENDINBLUE_API_KEY) {
archivist.attach(new Notifier(archivist.services));
} else {
logger.warn('Environment variable "SENDINBLUE_API_KEY" was not found; the Notifier module will be ignored');
}

if (process.env.GITHUB_TOKEN) {
Expand All @@ -49,8 +51,10 @@ export default async function track({ services, types, extractOnly, schedule })
await reporter.initialize();
archivist.attach(reporter);
} else {
logger.warn('Configuration key "reporter.githubIssues.repositories.declarations" was not found; the Reporter module will be ignored\n');
logger.warn('Configuration key "reporter.githubIssues.repositories.declarations" was not found; the Reporter module will be ignored');
}
} else {
logger.warn('Environment variable "GITHUB_TOKEN" was not found; the Notifier module will be ignored');
}

if (!schedule) {
Expand Down
2 changes: 1 addition & 1 deletion src/logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const consoleTransport = new winston.transports.Console();

const transports = [consoleTransport];

if (config.get('logger.sendMailOnError')) {
if (process.env.SMTP_PASSWORD && config.get('logger.sendMailOnError')) {
const mailerOptions = {
to: config.get('logger.sendMailOnError.to'),
from: config.get('logger.sendMailOnError.from'),
Expand Down

0 comments on commit 584b488

Please sign in to comment.