Skip to content

Commit

Permalink
v6: Fix default include dot paths (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
qetza committed Apr 23, 2024
1 parent 77cdb57 commit b0891ac
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@
## 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)).
- Fix default directories and files starting with a dot in sources and additional variables matching ([#29](https://github.com/qetza/replacetokens-task/issues/29)).

## 5.0.6
Task 6.0.5
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -148,6 +148,11 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens](
# Optional. Default: ignore
ifNoFilesFound: ''

# Include directories and files starting with a dot ('.') in glob matching results for sources and additionalVariables.
#
# Optional. Default: true
includeDotPaths: ''

# The log level.
#
# Accepted values:
Expand Down Expand Up @@ -332,6 +337,7 @@ The following **anonymous** data is send:
- _escape_
- _escapeChar_
- _ifNoFilesFound_
- _includeDotPaths_
- _logLevel_
- _missingVarAction_
- _missingVarDefault_
Expand Down
1 change: 1 addition & 0 deletions tasks/ReplaceTokensV6/CHANGELOG.md
@@ -1,6 +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)).
- Fix default directories and files starting with a dot 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
Expand Up @@ -148,6 +148,11 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens](
# Optional. Default: ignore
ifNoFilesFound: ''

# Include directories and files starting with a dot ('.') in glob matching results for sources and additionalVariables.
#
# Optional. Default: true
includeDotPaths: ''

# The log level.
#
# Accepted values:
Expand Down Expand Up @@ -332,6 +337,7 @@ The following **anonymous** data is send:
- _escape_
- _escapeChar_
- _ifNoFilesFound_
- _includeDotPaths_
- _logLevel_
- _missingVarAction_
- _missingVarDefault_
Expand Down
10 changes: 6 additions & 4 deletions tasks/ReplaceTokensV6/index.ts
Expand Up @@ -64,7 +64,8 @@ async function run() {
recursive: tl.getBoolInput('enableRecursion'),
root: tl.getPathInput('rootDirectory', false, true),
sources: {
caseInsensitive: tl.getBoolInput('caseInsensitivePaths')
caseInsensitive: tl.getBoolInput('caseInsensitivePaths'),
dot: tl.getBoolInput('includeDotPaths')
},
token: {
pattern:
Expand Down Expand Up @@ -115,7 +116,7 @@ async function run() {

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

// set telemetry attributes
telemetryEvent.setAttributes({
Expand All @@ -127,6 +128,7 @@ async function run() {
escape: options.escape.type,
'escape-char': options.escape.escapeChar,
'if-no-files-found': ifNoFilesFound,
'include-dot-paths': options.sources.dot,
'log-level': logLevelStr,
'missing-var-action': options.missing.action,
'missing-var-default': options.missing.default,
Expand Down Expand Up @@ -221,7 +223,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, caseInsensitive?: boolean): Promise<{ [key: string]: string }> {
var getAdditionalVariables = async function (root?: string, separator?: string, caseInsensitive?: boolean, dot?: boolean): Promise<{ [key: string]: string }> {
const input = tl.getInput('additionalVariables') || '';
if (!input) return {};

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

Expand Down
8 changes: 8 additions & 0 deletions tasks/ReplaceTokensV6/task.json
Expand Up @@ -79,6 +79,14 @@
"label": "Case insensitive paths",
"helpMarkDown": "Enable case-insensitive file path matching in glob patterns (sources and additionalVariables). Default: true"
},
{
"name": "includeDotPaths",
"type": "boolean",
"required": false,
"defaultValue": true,
"label": "Include dot paths",
"helpMarkDown": "Include directories and files starting with a dot ('.') in glob matching results (sources and additionalVariables). Default: true"
},
{
"name": "encoding",
"type": "pickList",
Expand Down

0 comments on commit b0891ac

Please sign in to comment.