From 8b3b4f4428d1c53cad2d6bd8ec7bcb20898e807a Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 24 Jan 2016 00:38:41 +0100 Subject: [PATCH] use `default-shell` module --- index.js | 7 ++++--- package.json | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 58783a1..21a76d2 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const childProcess = require('child_process'); const execa = require('execa'); const stripAnsi = require('strip-ansi'); -const shell = process.env.SHELL || '/bin/sh'; +const defaultShell = require('default-shell'); const user = process.env.USER; const opts = {encoding: 'utf8'}; @@ -11,7 +11,7 @@ function clean(str) { } function pathFromShell() { - return execa(shell, ['-i', '-c', 'echo "$PATH"']) + return execa(defaultShell, ['-i', '-c', 'echo "$PATH"']) .then(x => clean(x.stdout) || '') .catch(() => ''); } @@ -23,7 +23,8 @@ function pathFromSudo() { } function pathFromShellSync() { - return clean(childProcess.execFileSync(shell, ['-i', '-c', 'echo "$PATH"'], opts)) || ''; + const stdout = childProcess.execFileSync(defaultShell, ['-i', '-c', 'echo "$PATH"'], opts); + return clean(stdout) || ''; } function pathFromSudoSync() { diff --git a/package.json b/package.json index 6f7a0c3..c39ed00 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "nwjs" ], "dependencies": { + "default-shell": "^1.0.0", "execa": "^0.2.2", "strip-ansi": "^3.0.0" },