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.

26 lines
853 B

import {Host} from './Host'
import {ShellCommand} from './types'
import {Application, Awaitable, Filesystem, LocalFilesystem} from '@extollo/lib'
import {ExecutionResult} from './ExecutionResult'
import * as childProcess from 'child_process'
export class LocalHost extends Host {
async execute(command: ShellCommand): Promise<ExecutionResult> {
const result = new ExecutionResult()
return new Promise(res => {
childProcess.exec(command, (error, stdout, stderr) => {
result.exit(error?.code || 0)
result.out(stdout)
result.error(stderr)
res(result)
})
})
}
getFilesystem(): Awaitable<Filesystem> {
return Application.getContainer().makeNew<LocalFilesystem>(LocalFilesystem, {
baseDir: '/'
})
}
}