UNPKG

@dderevjanik/termux-api

Version:

This library allows you to interact with your Android device from Node.js using termux-api

20 lines (18 loc) 475 B
import { exec } from "child_process"; /** * Toggle LED Torch on device */ export async function torch(status: "on" | "off"): Promise<void> { return new Promise<void>((resolve, reject) => { const command = `termux-torch ${status}`; exec(command, (error, stdout, stderr) => { if (error) { return reject(`Error: ${error.message}`); } if (stderr) { return reject(`Error: ${stderr}`); } return resolve(); }); }); }