alapa
Version:
A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.
25 lines (24 loc) • 926 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.openFileWithVscode = void 0;
const child_process_1 = require("child_process");
const openFileWithVscode = (req, res) => {
if (process.env.NODE_ENV !== "development") {
return res.status(403).json({
error: "Access denied. This endpoint is only accessible in development mode.",
});
}
const { filePath } = req.body;
const cleanPath = filePath.replace(/\)/g, "");
// Construct the command
const command = `code --reuse-window --goto ${cleanPath}`;
// Execute the command
(0, child_process_1.exec)(command, (error, stdout, stderr) => {
if (error) {
return res.status(500).json({ error: "Failed to open file" });
}
res.status(200).json({ message: "File opened successfully" });
});
return;
};
exports.openFileWithVscode = openFileWithVscode;
;