|
|
const { exec } = require('child_process'); |
|
|
const vscode = require('vscode'); |
|
|
const path = require('path'); |
|
|
const convertWindowsToUnixPath = require('./utilities/convertPathWindowsToUnix'); |
|
|
|
|
|
|
|
|
function eseguiScriptBash(srcFile) { |
|
|
return new Promise((resolve, reject) => { |
|
|
const tool_path = convertWindowsToUnixPath(path.join(__dirname,`../launch_tool`)); |
|
|
const tool_starter = convertWindowsToUnixPath(path.join(__dirname,`../launch_tool/patchitpy_starter.sh`)); |
|
|
const convertedSrcFile = convertWindowsToUnixPath(srcFile); |
|
|
|
|
|
const comando = "wsl " + tool_starter + " " + convertedSrcFile + " " + tool_path; |
|
|
|
|
|
vscode.window.showInformationMessage("[PatchitPy]: Tool is running"); |
|
|
|
|
|
|
|
|
exec(comando, (error, stdout, stderr) => { |
|
|
if (error) { |
|
|
vscode.window.showErrorMessage(`[PatchitPy]: Error during execution of the script: ${error}`); |
|
|
reject(error); |
|
|
return; |
|
|
} |
|
|
if (stderr) { |
|
|
vscode.window.showErrorMessage(`[PatchitPy]: Error in the script: ${stderr}`); |
|
|
reject(stderr); |
|
|
return; |
|
|
} |
|
|
|
|
|
vscode.window.showInformationMessage("[PatchitPy]: Detection executed"); |
|
|
|
|
|
|
|
|
const match = stdout.match(/runtime=(.*)/); |
|
|
if (match) { |
|
|
vscode.window.showInformationMessage("[PatchitPy]: Runtime: " + parseFloat(match[1].trim()).toFixed(3) + " seconds"); |
|
|
} |
|
|
else { |
|
|
vscode.window.showWarningMessage("[PatchitPy]: Errore definizione runtime"); |
|
|
} |
|
|
|
|
|
resolve(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
module.exports = eseguiScriptBash; |