Skip to content

Commit

Permalink
fix(ui5-task-copyright): align env var names (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermuessig authored Feb 21, 2024
1 parent 3efb142 commit 7cd4501
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions packages/ui5-task-copyright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ npm install ui5-task-copyright --save-dev

## Configuration options (in `$yourapp/ui5.yaml`)

- copyright: `String` (via env var: `UI5_TASK_COPYRIGHT_FILE` expects file name)
the value of the copyright or the path to a file containing the copyright statement - if not given, the task will be skipped - the copyright can also be injected by the environment variable `UI5_TASK_COPYRIGHT_FILE` which must point to an existing file and then the copyright is extracted from this file
- copyright: `String` (via env var: `ui5_task_copyright__file` expects file name)
the value of the copyright or the path to a file containing the copyright statement - if not given, the task will be skipped - the copyright can also be injected by the environment variable `ui5_task_copyright__file` which must point to an existing file and then the copyright is extracted from this file

- copyrightPlaceholder: `String` (defaults to: `copyright`, env var: `UI5_TASK_COPYRIGHT_PLACEHOLDER_COPYRIGHT`)
- copyrightPlaceholder: `String` (defaults to: `copyright`, env var: `ui5_task_copyright__placeholder_copyright`)
the name of the copyright placeholder to check for in the copyright comments and to replace with the copyright value (will replace all hits of `${copyright}` or `@copyright@`)

- currentYearPlaceholder: `String` (defaults to: `currentYear`, env var: `UI5_TASK_COPYRIGHT_PLACEHOLDER_CURRENT_YEAR`)
- currentYearPlaceholder: `String` (defaults to: `currentYear`, env var: `ui5_task_copyright__placeholder_current_year`)
the name of the currentYear placeholder in the copyright comments which will be replaced with the currentYear value (will replace all hits of `${currentYear}` or `@currentYear@`)

- excludePatterns: `Array<String>`
Expand Down
22 changes: 11 additions & 11 deletions packages/ui5-task-copyright/lib/copyright.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { XMLParser } = require("fast-xml-parser");
*/
module.exports = async ({ log, workspace, options }) => {
// disable task if no copyright is configured
if (!options?.configuration?.copyright && !process.env.UI5_TASK_COPYRIGHT_FILE) {
if (!options?.configuration?.copyright && !process.env.ui5_task_copyright__file) {
return Promise.resolve();
}

Expand All @@ -27,13 +27,13 @@ module.exports = async ({ log, workspace, options }) => {
);

// the environment variable UI5_TASK_COPYRIGHT_PLACEHOLDER_* can be used to override the placeholders
if (process.env.UI5_TASK_COPYRIGHT_PLACEHOLDER_COPYRIGHT) {
copyrightPlaceholder = process.env.UI5_TASK_COPYRIGHT_PLACEHOLDER_COPYRIGHT;
log.info(`Using environment variable UI5_TASK_COPYRIGHT_PLACEHOLDER_COPYRIGHT: ${copyrightPlaceholder}`);
if (process.env.ui5_task_copyright__placeholder_copyright) {
copyrightPlaceholder = process.env.ui5_task_copyright__placeholder_copyright;
log.info(`Using environment variable ui5_task_copyright__placeholder_copyright: ${copyrightPlaceholder}`);
}
if (process.env.UI5_TASK_COPYRIGHT_PLACEHOLDER_CURRENT_YEAR) {
currentYearPlaceholder = process.env.UI5_TASK_COPYRIGHT_PLACEHOLDER_CURRENT_YEAR;
log.info(`Using environment variable UI5_TASK_COPYRIGHT_PLACEHOLDER_CURRENT_YEAR: ${currentYearPlaceholder}`);
if (process.env.ui5_task_copyright__placeholder_current_year) {
currentYearPlaceholder = process.env.ui5_task_copyright__placeholder_current_year;
log.info(`Using environment variable ui5_task_copyright__placeholder_current_year: ${currentYearPlaceholder}`);
}

// only words are allowed as placeholders
Expand Down Expand Up @@ -63,10 +63,10 @@ module.exports = async ({ log, workspace, options }) => {
options.configuration
);

// the environment variable UI5_TASK_COPYRIGHT_FILE can be used to specify a file path for the copyright
if (process.env.UI5_TASK_COPYRIGHT_FILE) {
copyright = process.env.UI5_TASK_COPYRIGHT_FILE;
log.info(`Using environment variable UI5_TASK_COPYRIGHT_FILE: ${copyright}`);
// the environment variable ui5_task_copyright__file can be used to specify a file path for the copyright
if (process.env.ui5_task_copyright__file) {
copyright = process.env.ui5_task_copyright__file;
log.info(`Using environment variable ui5_task_copyright__file: ${copyright}`);
}

// check if the file exists (if copyright is a file path)
Expand Down
4 changes: 2 additions & 2 deletions packages/ui5-task-copyright/test/copyright.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ test("Copyright from file (env)", async (t) => {
shell: true,
cwd: path.resolve(__dirname, "../../../showcases/ui5-tsapp"),
env: Object.assign({}, process.env, {
UI5_TASK_COPYRIGHT_FILE: "./copyright-alt.txt",
UI5_TASK_COPYRIGHT_PLACEHOLDER_CURRENT_YEAR: "altCurrentYear",
ui5_task_copyright__file: "./copyright-alt.txt",
ui5_task_copyright__placeholder_current_year: "altCurrentYear",
}),
});

Expand Down

0 comments on commit 7cd4501

Please sign in to comment.