Skip to content

Commit

Permalink
Added globals
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth-hk committed Mar 31, 2020
1 parent 542eb45 commit 044a404
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions commands/sxglobal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// modules
const path = require("path");
const exec = require("child_process").exec;
const os = require("os");

// imports
var sxconfig = require(path.join(__dirname, "..", "sxconfig.json"));

function sxglobal(index, key) {
if (os.type() == "Windows_NT") {
exec(`explorer ${sxconfig.Globals[index][key]}`, err => {
console.log(`Opening ${sxconfig.Globals[index][key]}...`);
});
} else if (os.type() == "Linux") {
exec(`xdg-open ${sxconfig.Globals[index][key]}`, err => {
console.log(`Opening ${sxconfig.Globals[index][key]}...`);
});
} else if (os.type() == "Darwin") {
exec(`open ${sxconfig.Globals[index][key]}`, err => {
console.log(`Opening ${sxconfig.Globals[index][key]}...`);
});
} else {
console.log("Your OS is not supported");
}
}

module.exports = sxglobal;

0 comments on commit 044a404

Please sign in to comment.