-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9785fe
commit 86a3401
Showing
5 changed files
with
33 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
const { sudo } = require("../utils/sudo"); | ||
const { spawnSync } = require("child_process"); | ||
const { execSync } = require("child_process"); | ||
|
||
const installCommandGeneric = (commands, os, variant, config) => { | ||
const command = commands[variant?.toLowerCase()] || commands[os]; | ||
if (!command) { | ||
return null; | ||
return false; | ||
} | ||
const stdio = config.log > 2 ? "inherit" : "ignore"; | ||
spawnSync(sudo(command), { stdio }); | ||
execSync(sudo(command), { stdio }); | ||
return true; | ||
}; | ||
|
||
module.exports.installCommandGeneric = installCommandGeneric; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,60 @@ | ||
const { managers } = require("../os"); | ||
const { sudo } = require("../utils/sudo"); | ||
const { spawnSync } = require("child_process"); | ||
const { execSync } = require("child_process"); | ||
|
||
const installCommandLinux = (commands, variant, config) => { | ||
const command = commands[variant] || commands.linux; | ||
if (!command) { | ||
return null; | ||
return false; | ||
} | ||
if (variant === "ubuntu") { | ||
const name = command.match(/apt-get install (.*)/)?.[1]; | ||
if (!name) { | ||
return null; | ||
return false; | ||
} | ||
managers.ubuntu.repo.update([], config); | ||
return managers.ubuntu.install([name], [], config); | ||
managers.ubuntu.install([name], [], config); | ||
return true; | ||
} | ||
if (variant === "debian") { | ||
const name = command.match(/apt-get install (.*)/)?.[1]; | ||
if (!name) { | ||
return null; | ||
return false; | ||
} | ||
managers.debian.repo.update([], config); | ||
return managers.debian.install([name], [], config); | ||
managers.debian.install([name], [], config); | ||
return true; | ||
} | ||
if (variant === "raspbian") { | ||
const name = command.match(/apt-get install (.*)/)?.[1]; | ||
if (!name) { | ||
return null; | ||
return false; | ||
} | ||
managers.raspbian.repo.update([], config); | ||
return managers.raspbian.install([name], [], config); | ||
managers.raspbian.install([name], [], config); | ||
return true; | ||
} | ||
if (variant === "arch") { | ||
const name = command.match(/pacman -S (.*)/)?.[1]; | ||
if (!name) { | ||
return null; | ||
return false; | ||
} | ||
managers.arch.repo.update([], config); | ||
return managers.arch.install([name], [], config); | ||
managers.arch.install([name], [], config); | ||
return true; | ||
} | ||
if (variant === "alpine") { | ||
const name = command.match(/apk add (.*)/)?.[1]; | ||
if (!name) { | ||
return null; | ||
return false; | ||
} | ||
managers.alpine.repo.update([], config); | ||
return managers.alpine.install([name], [], config); | ||
managers.alpine.install([name], [], config); | ||
return true; | ||
} | ||
const stdio = config.log > 2 ? "inherit" : "ignore"; | ||
spawnSync(sudo(command), { stdio }); | ||
execSync(sudo(command), { stdio }); | ||
return true; | ||
}; | ||
|
||
module.exports.installCommandLinux = installCommandLinux; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
const { sudo } = require("../utils/sudo"); | ||
const { spawnSync } = require("child_process"); | ||
const { execSync } = require("child_process"); | ||
|
||
const installCommandWindows = (commands, config) => { | ||
const command = commands["windows"] || commands["win32"]; | ||
if (!command) { | ||
return null; | ||
return false; | ||
} | ||
const stdio = config.log > 2 ? "inherit" : "ignore"; | ||
spawnSync(sudo(command), { stdio }); | ||
execSync(sudo(command), { stdio }); | ||
return true; | ||
}; | ||
|
||
module.exports.installCommandWindows = installCommandWindows; |