Skip to content

Commit

Permalink
Add extension filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kiliczsh committed May 1, 2021
1 parent 0c275e8 commit e6a1e9e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .idea/workspace.xml

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

4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: 'Path to search for codebase'
required: false
default: '.'
extension-filter:
description: 'Filter extension for files'
required: false
default: '.js'
outputs:
result:
description: 'The list of scan-keyword input in codebase'
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8589,22 +8589,22 @@ try {

const keyword = core.getInput('scan-keyword');
const codebasepath = core.getInput('codebase-path');
const extension = core.getInput('extension-filter');
extension.concat('$');
console.log(`Searching for ${keyword} in ${codebasepath}!`);

let scanResult = null;
fif.find(keyword, codebasepath, '.js$')
let scanResult = "";
fif.find(keyword, codebasepath, extension)
.then(function(results) {
for (let result in results) {
let res = results[result];
let msg = 'Found "' + res.matches[0] + '" ' + res.count
+ ' times in "' + result + '"';
scanResult += msg + "\r\n";
scanResult.concat(msg+ "\r\n");
}
});
if(scanResult === null){
scanResult = "No results found!";
}
console.log(scanResult);
core.setOutput("result", scanResult);
} catch (error) {
core.setFailed(error.message);
}
Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ try {

const keyword = core.getInput('scan-keyword');
const codebasepath = core.getInput('codebase-path');
const extension = core.getInput('extension-filter');
extension.concat('$');
console.log(`Searching for ${keyword} in ${codebasepath}!`);

let scanResult = null;
fif.find(keyword, codebasepath, '.js$')
let scanResult = "";
fif.find(keyword, codebasepath, extension)
.then(function(results) {
for (let result in results) {
let res = results[result];
let msg = 'Found "' + res.matches[0] + '" ' + res.count
+ ' times in "' + result + '"';
scanResult += msg + "\r\n";
scanResult.concat(msg+ "\r\n");
}
});
if(scanResult === null){
scanResult = "No results found!";
}
console.log(scanResult);
core.setOutput("result", scanResult);
} catch (error) {
core.setFailed(error.message);
}

0 comments on commit e6a1e9e

Please sign in to comment.