MCPcopy
hub / github.com/wg-easy/wg-easy / exec

Function exec

src/server/utils/cmd.ts:6–32  ·  view source on GitHub ↗
(
  cmd: string,
  { log }: { log: boolean | string } = { log: true }
)

Source from the content-addressed store, hash-verified

4const CMD_DEBUG = createDebug('CMD');
5
6export function exec(
7 cmd: string,
8 { log }: { log: boolean | string } = { log: true }
9) {
10 if (typeof log === 'string') {
11 CMD_DEBUG(`$ ${log}`);
12 } else if (log === true) {
13 CMD_DEBUG(`$ ${cmd}`);
14 }
15
16 if (process.platform !== 'linux') {
17 return Promise.resolve('');
18 }
19
20 return new Promise<string>((resolve, reject) => {
21 childProcess.exec(
22 cmd,
23 {
24 shell: 'bash',
25 },
26 (err, stdout) => {
27 if (err) return reject(err);
28 return resolve(String(stdout).trim());
29 }
30 );
31 });
32}

Callers 8

detectAwgFunction · 0.85
wgHelper.tsFile · 0.85
initChainFunction · 0.85
flushChainFunction · 0.85
applyClientRulesFunction · 0.85
rebuildRulesFunction · 0.85
removeFilteringFunction · 0.85
isAvailableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected