diff --git a/packages/ui5-task-copyright/README.md b/packages/ui5-task-copyright/README.md index c41c954b8..7aad600b1 100644 --- a/packages/ui5-task-copyright/README.md +++ b/packages/ui5-task-copyright/README.md @@ -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` diff --git a/packages/ui5-task-copyright/lib/copyright.js b/packages/ui5-task-copyright/lib/copyright.js index a59b7583f..0fab791cb 100644 --- a/packages/ui5-task-copyright/lib/copyright.js +++ b/packages/ui5-task-copyright/lib/copyright.js @@ -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(); } @@ -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 @@ -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) diff --git a/packages/ui5-task-copyright/test/copyright.test.js b/packages/ui5-task-copyright/test/copyright.test.js index 8a020de6c..8a3239413 100644 --- a/packages/ui5-task-copyright/test/copyright.test.js +++ b/packages/ui5-task-copyright/test/copyright.test.js @@ -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", }), });