util: Add general subprocess helper

This commit is contained in:
Danny Lin 2021-11-21 19:43:39 -08:00
parent e29ddb5baf
commit 31a18c6697
3 changed files with 8 additions and 4 deletions

View file

@ -3,7 +3,7 @@ import * as path from 'path'
import * as xml2js from 'xml2js'
import { serializeBlueprint } from '../build/soong'
import { aapt2 } from '../util/aapt2'
import { aapt2 } from '../util/process'
import { exists, listFilesRecursive } from '../util/fs'
import { XML_HEADER } from '../util/headers'
import { parseLines } from '../util/parse'

View file

@ -2,7 +2,7 @@ import { promises as fs } from 'fs'
import * as path from 'path'
import { parseSeappContexts } from '../sepolicy/seapp'
import { aapt2 } from '../util/aapt2'
import { aapt2 } from '../util/process'
import { listFilesRecursive } from '../util/fs'
import { BlobEntry } from './entry'

View file

@ -3,8 +3,12 @@ import { exec as execCb } from 'child_process'
const exec = util.promisify(execCb)
export async function aapt2(path: string, ...args: Array<string>) {
export async function run(command: string) {
// TODO: stop using shell
let { stdout, stderr } = await exec(`${path} ${args.join(' ')}`)
let { stdout } = await exec(command)
return stdout.trim()
}
export async function aapt2(path: string, ...args: Array<string>) {
return await run(`${path} ${args.join(' ')}`)
}