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) 474 B
import { exec } from "child_process"; /** * Toggle Wi-Fi On/Off */ export async function wifiEnable(enable: boolean): Promise<void> { return new Promise<void>((resolve, reject) => { const command = `termux-wifi-enable ${enable}`; exec(command, (error, stdout, stderr) => { if (error) { return reject(`Error: ${error.message}`); } if (stderr) { return reject(`Error: ${stderr}`); } return resolve(); }); }); }