PatchitPy / extension_PatchitPy /src /RunPatchitpyFromFile.js
piliguori's picture
Upload 3316 files
6e7eaf3 verified
raw
history blame
1.14 kB
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;
// Verifica il tipo di percorso
fs.stat(filePath, (err, stats) => {
if (err) {
reject(err); // Gestisci errori di lettura del file system
return;
}
if (stats.isFile()) {
// Esegui solo se è un file
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;