You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
697 B
31 lines
697 B
import { spawnSync } from 'child_process'; |
|
|
|
import SERVER_PATHS from './consts/SERVER_PATHS'; |
|
|
|
const systemCall = ( |
|
...[command, args = [], options = {}]: Parameters<typeof spawnSync> |
|
) => { |
|
const { error, stderr, stdout } = spawnSync(command, args, { |
|
...options, |
|
encoding: 'utf-8', |
|
}); |
|
|
|
if (error) { |
|
throw error; |
|
} |
|
|
|
if (stderr) { |
|
throw new Error(stderr); |
|
} |
|
|
|
return stdout; |
|
}; |
|
|
|
export const date = (...args: string[]) => |
|
systemCall(SERVER_PATHS.usr.bin.date.self, args); |
|
|
|
export const mkfifo = (...args: string[]) => |
|
systemCall(SERVER_PATHS.usr.bin.mkfifo.self, args); |
|
|
|
export const rm = (...args: string[]) => |
|
systemCall(SERVER_PATHS.usr.bin.rm.self, args);
|
|
|