|
|
const fs = require('fs'); |
|
|
const path = require('path'); |
|
|
const vscode = require('vscode'); |
|
|
const execPatchitpy = require('./execPatchitpy'); |
|
|
|
|
|
function runPatchitpyFromFile(uri) { |
|
|
return new Promise((resolve, reject) => { |
|
|
const filePath = uri.fsPath; |
|
|
|
|
|
|
|
|
fs.stat(filePath, (err, stats) => { |
|
|
if (err) { |
|
|
reject(err); |
|
|
return; |
|
|
} |
|
|
|
|
|
if (stats.isFile()) { |
|
|
|
|
|
execPatchitpy(filePath) |
|
|
.then(() => { |
|
|
console.log("PatchitPy Executed"); |
|
|
resolve(); |
|
|
}) |
|
|
.catch((err) => { |
|
|
reject(err); |
|
|
}); |
|
|
} else { |
|
|
vscode.window.showErrorMessage(`Error executing tool: the path ${filePath} is not a file`); |
|
|
reject(new Error(`Il percorso ${filePath} non è un file.`)); |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
module.exports = runPatchitpyFromFile; |
|
|
|