Skip to content

Commit

Permalink
executer for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Güdür committed May 30, 2023
1 parent 4ee37ac commit 02e13a8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/mac-current-connections.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const execute = require('./utils/executer');
const execute = require('./utils/executerForMac');
const promiser = require('./utils/promiser');
const command = require('./macOS/current-connections/command.js');
const parse = require('./macOS/current-connections/parser');
Expand Down
2 changes: 1 addition & 1 deletion src/mac-scan.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const execute = require('./utils/executer');
const execute = require('./utils/executerForMac');
const promiser = require('./utils/promiser');
const command = require('./macOS/scan/command.js');
const parse = require('./macOS/scan/parser');
Expand Down
4 changes: 2 additions & 2 deletions src/macOS/current-connections/command.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const command = () => ({
cmd: 'sudo',
args: ['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport', '--getinfo']
cmd: '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport',
args: ['--getinfo']
});

module.exports = command;
3 changes: 1 addition & 2 deletions src/utils/executer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { execFile } = require('child_process');
const sudo = require('sudo-prompt');
const env = require('../env');

module.exports = ({ cmd, args }) =>
new Promise((resolve, reject) => {
sudo.exec(`${cmd} ${args.join(' ')}`, {}, (error, output) => {
execFile(cmd, { args }, (error, output) => {
if (error) {
reject(error);
} else {
Expand Down
14 changes: 14 additions & 0 deletions src/utils/executerForMac.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { execFile } = require('child_process');
const sudo = require('sudo-prompt');
const env = require('../env');

module.exports = ({ cmd, args }) =>
new Promise((resolve, reject) => {
sudo.exec(`${cmd} ${args.join(' ')}`, {}, (error, output) => {
if (error) {
reject(error);
} else {
resolve(output);
}
});
});

0 comments on commit 02e13a8

Please sign in to comment.