Skip to content

Commit

Permalink
Using execa to execute openvpn
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigogs committed Jun 24, 2017
1 parent be07c1c commit aaa2432
Show file tree
Hide file tree
Showing 4 changed files with 1,717 additions and 28 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path');
const os = require('os');
const fs = require('fs');
const spawn = require('child_process').spawn;
const execa = require('execa');
const Promise = require('bluebird');
const which = require('which');
const prompt = require('prompt');
Expand Down Expand Up @@ -58,7 +58,7 @@ const save = (vpns) => {
const startOpenvpn = (options = []) => {
logger.info('Starting openvpn...');
const openvpn = `"${which.sync('openvpn')}"`;
const proc = spawn(openvpn, ['--config', `"${filePath}"`].concat(options), { shell: true });
const proc = execa(openvpn, ['--config', `"${filePath}"`].concat(options), { shell: true });
proc.stdout.pipe(logger.stream);
proc.stderr.on('data', data => logger.error(data.toString()));
proc.on('close', code => logger.info(`child process exited with code ${code}`));
Expand Down
Loading

0 comments on commit aaa2432

Please sign in to comment.