Implemented shutdown through UI and implemented router check
This commit is contained in:
30
dist/Shutdown.js
vendored
Normal file
30
dist/Shutdown.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.shutdown = shutdown;
|
||||
var child_process_1 = require("child_process");
|
||||
function shutdown() {
|
||||
if (process.platform === 'win32') {
|
||||
return shutdownWindows();
|
||||
}
|
||||
return Promise.resolve({
|
||||
succeed: false,
|
||||
message: 'Platform not supported',
|
||||
});
|
||||
}
|
||||
function shutdownWindows() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
(0, child_process_1.exec)('shutdown /s /t 5', function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
console.error("Error shutting down Windows: ".concat(error.message));
|
||||
return resolve({ succeed: false, message: error.message });
|
||||
}
|
||||
if (stderr) {
|
||||
console.error("Error shutting down Windows: ".concat(stderr));
|
||||
return resolve({ succeed: false, message: stderr });
|
||||
}
|
||||
console.log("Windows shutdown command executed: ".concat(stdout));
|
||||
resolve({ succeed: true });
|
||||
});
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=Shutdown.js.map
|
||||
Reference in New Issue
Block a user