mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Improve getFileType
- Change parameter name - Add more documentation
This commit is contained in:
10
lib/actions-util.js
generated
10
lib/actions-util.js
generated
@@ -382,12 +382,16 @@ function getWorkflowRunAttempt() {
|
||||
exports.getWorkflowRunAttempt = getWorkflowRunAttempt;
|
||||
/**
|
||||
* Tries to obtain the output of the `file` command for the file at the specified path.
|
||||
* The output will vary depending on the type of `file`, which operating system we are running on, etc.
|
||||
*/
|
||||
const getFileType = async (fp) => {
|
||||
const getFileType = async (filePath) => {
|
||||
let stderr = "";
|
||||
let stdout = "";
|
||||
try {
|
||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("file"), ["-L", fp], {
|
||||
// The `file` command will output information about the type of file pointed at by `filePath`.
|
||||
// For binary files, this may include e.g. whether they are static of dynamic binaries.
|
||||
// The `-L` switch instructs the command to follow symbolic links.
|
||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("file"), ["-L", filePath], {
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
@@ -401,7 +405,7 @@ const getFileType = async (fp) => {
|
||||
return stdout;
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`Could not determine type of ${fp} from ${stdout}. ${stderr}`);
|
||||
core.info(`Could not determine type of ${filePath} from ${stdout}. ${stderr}`);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user