Skip to content

Execute shell commands for ios/android devices from react-native

Notifications You must be signed in to change notification settings

jacobclyne/react-native-command-executer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-command-executor

Getting started

$ npm install react-native-command-executor --save

Mostly automatic installation

$ react-native link react-native-command-executor

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.imokhles.sncommandexecutor.SNCommandExecutorPackage; to the imports at the top of the file
  • Add new SNCommandExecutorPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-command-executor'
    project(':react-native-command-executor').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-command-executor/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-command-executor')
    

Usage

import SNCommandExecutor from 'react-native-command-executor';

// Check Root status
SNCommandExecutor.verifyRootStatus((value) => {
    console.log('root status: '+value);
});

// execute command
let executed = SNCommandExecutor.executeCommand("which su");
console.log('Executed: '+ executed);

About

Execute shell commands for ios/android devices from react-native

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 97.7%
  • JavaScript 2.3%