Skip to content

Commit

Permalink
Fix invalid variables in js code
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolajgs committed Oct 30, 2023
1 parent ed5b853 commit 0b3a566
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 deletions replace-string/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30052,31 +30052,30 @@ try {
}

// Action
strToReplace = '';
strEncoding = (inReadEncoding != '' ? inReadEncoding : 'utf-8');
outReplacedString = '';
outEncoding = (inReadEncoding != '' ? inReadEncoding : 'utf-8');
if (inReadFromFile != '') {
strToReplace = fs.readFileSync(inReadFromFile, strEncoding);
outReplacedString = fs.readFileSync(inReadFromFile, outEncoding);
} else {
strToReplace = inString;
outReplacedString = inString;
}

if (inReplaceRegexArr.length > 1) {
for (i=0; i<inReplaceRegexArr.length; i++) {
const regex = new RegExp(inReplaceRegexArr[i], inFlags);
console.log('Replace '+regex+' with '+inReplaceWithArr[i])
strReplaced = strToReplace.replace(regex, inReplaceWithArr[i]);
outReplacedString = outReplacedString.replace(regex, inReplaceWithArr[i]);
}
} else {
const regex = new RegExp(inReplaceRegex, inFlags);
strReplaced = strToReplace.replace(regex, inReplaceWith);
outReplacedString = outReplacedString.replace(regex, inReplaceWith);
}

// Output
if (inWriteToFile != '') {
fs.writeFileSync(inWriteToFile, strReplaced);
fs.writeFileSync(inWriteToFile, outReplacedString);
}

core.setOutput('replaced-string', strReplaced);
core.setOutput('replaced-string', outReplacedString);
} catch (error) {
core.setFailed(error.message);
}
Expand Down
17 changes: 8 additions & 9 deletions replace-string/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,30 @@ try {
}

// Action
strToReplace = '';
strEncoding = (inReadEncoding != '' ? inReadEncoding : 'utf-8');
outReplacedString = '';
outEncoding = (inReadEncoding != '' ? inReadEncoding : 'utf-8');
if (inReadFromFile != '') {
strToReplace = fs.readFileSync(inReadFromFile, strEncoding);
outReplacedString = fs.readFileSync(inReadFromFile, outEncoding);
} else {
strToReplace = inString;
outReplacedString = inString;
}

if (inReplaceRegexArr.length > 1) {
for (i=0; i<inReplaceRegexArr.length; i++) {
const regex = new RegExp(inReplaceRegexArr[i], inFlags);
console.log('Replace '+regex+' with '+inReplaceWithArr[i])
strReplaced = strToReplace.replace(regex, inReplaceWithArr[i]);
outReplacedString = outReplacedString.replace(regex, inReplaceWithArr[i]);
}
} else {
const regex = new RegExp(inReplaceRegex, inFlags);
strReplaced = strToReplace.replace(regex, inReplaceWith);
outReplacedString = outReplacedString.replace(regex, inReplaceWith);
}

// Output
if (inWriteToFile != '') {
fs.writeFileSync(inWriteToFile, strReplaced);
fs.writeFileSync(inWriteToFile, outReplacedString);
}

core.setOutput('replaced-string', strReplaced);
core.setOutput('replaced-string', outReplacedString);
} catch (error) {
core.setFailed(error.message);
}

0 comments on commit 0b3a566

Please sign in to comment.