Skip to content

Commit

Permalink
v6: Fix default case insensitive paths (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
qetza authored Apr 23, 2024
1 parent b21cc8e commit 77cdb57
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## 5.0.7
Task 6.0.6
- Fix default case sensitivity in sources and additional variables matching ([#29](https://github.com/qetza/replacetokens-task/issues/29)).

## 5.0.6
Task 6.0.5
- Fix normalized variable names not supported as token name ([#15](https://github.com/qetza/replacetokens-task/issues/15)) ([#20](https://github.com/qetza/replacetokens-task/issues/20)).
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens](
# Optional.
additionalVariables: ''

# Enable case-insensitive file path matching in glob patterns for sources and additionalVariables.
#
# Optional. Default: true
caseInsensitivePaths: ''

# The characters to escape when using 'custom' escape.
#
# Optional.
Expand Down Expand Up @@ -321,6 +326,7 @@ The following **anonymous** data is send:
- the agent OS (`Windows`, `macOS` or `Linux`)
- the inputs values for
- _addBOM_
- _caseInsensitivePaths_
- _charsToEscape_
- _encoding_
- _escape_
Expand Down
3 changes: 3 additions & 0 deletions tasks/ReplaceTokensV6/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## 6.0.6
- Fix default case sensitivity in sources and additional variables matching ([#29](https://github.com/qetza/replacetokens-task/issues/29)).

## 6.0.5
- Fix normalized variable names not supported as token name ([#15](https://github.com/qetza/replacetokens-task/issues/15)) ([#20](https://github.com/qetza/replacetokens-task/issues/20)).

Expand Down
6 changes: 6 additions & 0 deletions tasks/ReplaceTokensV6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens](
# Optional.
additionalVariables: ''

# Enable case-insensitive file path matching in glob patterns for sources and additionalVariables.
#
# Optional. Default: true
caseInsensitivePaths: ''

# The characters to escape when using 'custom' escape.
#
# Optional.
Expand Down Expand Up @@ -321,6 +326,7 @@ The following **anonymous** data is send:
- the agent OS (`Windows`, `macOS` or `Linux`)
- the inputs values for
- _addBOM_
- _caseInsensitivePaths_
- _charsToEscape_
- _encoding_
- _escape_
Expand Down
10 changes: 7 additions & 3 deletions tasks/ReplaceTokensV6/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ async function run() {
},
recursive: tl.getBoolInput('enableRecursion'),
root: tl.getPathInput('rootDirectory', false, true),
sources: {
caseInsensitive: tl.getBoolInput('caseInsensitivePaths')
},
token: {
pattern:
getChoiceInput('tokenPattern', [
Expand Down Expand Up @@ -112,12 +115,13 @@ async function run() {

// load additional variables
const separator = tl.getInput('variableSeparator') || rt.Defaults.Separator;
const additionalVariables = await getAdditionalVariables(options.root, separator);
const additionalVariables = await getAdditionalVariables(options.root, separator, options.sources.caseInsensitive);

// set telemetry attributes
telemetryEvent.setAttributes({
sources: sources.length,
'add-bom': options.addBOM,
'case-insenstive-paths': options.sources.caseInsensitive,
'chars-to-escape': options.escape.chars,
encoding: options.encoding,
escape: options.escape.type,
Expand Down Expand Up @@ -217,7 +221,7 @@ var getChoiceInput = function (name: string, choices: string[], alias?: string):
var variableFilesCount = 0;
var variablesEnvCount = 0;
var inlineVariablesCount = 0;
var getAdditionalVariables = async function (root?: string, separator?: string): Promise<{ [key: string]: string }> {
var getAdditionalVariables = async function (root?: string, separator?: string, caseInsensitive?: boolean): Promise<{ [key: string]: string }> {
const input = tl.getInput('additionalVariables') || '';
if (!input) return {};

Expand All @@ -236,7 +240,7 @@ var getAdditionalVariables = async function (root?: string, separator?: string):
return getAdditionalVariablesFromYaml(input);
}
})(),
{ normalizeWin32: true, root: root, separator: separator }
{ caseInsensitive: caseInsensitive, normalizeWin32: true, root: root, separator: separator }
);
};

Expand Down
14 changes: 7 additions & 7 deletions tasks/ReplaceTokensV6/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tasks/ReplaceTokensV6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/sdk-trace-base": "^1.22.0",
"@opentelemetry/semantic-conventions": "^1.22.0",
"@qetza/replacetokens": "^1.5.0",
"@qetza/replacetokens": "^1.6.0",
"axios": "^1.6.7",
"azure-pipelines-task-lib": "^4.1.0",
"js-yaml": "^4.1.0",
Expand Down
10 changes: 9 additions & 1 deletion tasks/ReplaceTokensV6/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 6,
"Minor": 0,
"Patch": 5
"Patch": 6
},
"releaseNotes": "breaking changes, see [changelog](https://github.com/qetza/replacetokens-task/blob/master/tasks/ReplaceTokensV6/CHANGELOG.md)",
"instanceNameFormat": "Replace tokens",
Expand Down Expand Up @@ -71,6 +71,14 @@
"label": "Token suffix",
"helpMarkDown": "The token suffix when using 'custom' token pattern."
},
{
"name": "caseInsensitivePaths",
"type": "boolean",
"required": false,
"defaultValue": true,
"label": "Case insensitive paths",
"helpMarkDown": "Enable case-insensitive file path matching in glob patterns (sources and additionalVariables). Default: true"
},
{
"name": "encoding",
"type": "pickList",
Expand Down
Loading

0 comments on commit 77cdb57

Please sign in to comment.