Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #58 bug #66

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions setCwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ const { promisify } = require('util');

const promiseExec = promisify(exec);

const setCwd = async ({ dispatch, action, tab }) => {
const newCwd = await promiseExec(
`lsof -a -p ${tab.pid} -d cwd -Fn | tail -1 | sed 's/.//'`);
// Since Node v8, return type of a promisified exec has changed:
// https://github.com/nodejs/node/commit/fe5ca3ff27
const cwd = typeof newCwd === 'string' ? newCwd.trim() : newCwd.stdout.trim();
dispatch({
type: 'SESSION_SET_CWD',
cwd,
const setCwd = ({dispatch, action, tab}) => {
return promiseExec(
`LANG=en_US.utf-8 lsof -n -p ${
tab.pid
} | grep cwd | tr -s ' ' | cut -d ' ' -f9-`
).then((newCwd) => {
const cwd = (newCwd.stdout || newCwd).trim();
dispatch({type: "SESSION_SET_CWD", cwd});
});
};

Expand Down