Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 513993e

Browse files
committed
Set the working directory
Set the CWD for clang to that of the Atom project, if that is unable to be determined use the directory of the file itself.
1 parent ce0b4a5 commit 513993e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// eslint-disable-next-line import/extensions, import/no-extraneous-dependencies
44
import { CompositeDisposable } from 'atom';
5+
import { dirname } from 'path';
56

67
let helpers = null;
78
let clangFlags = null;
@@ -132,9 +133,15 @@ export default {
132133

133134
args.push(filePath);
134135

136+
let [projectPath] = atom.project.relativizePath(filePath);
137+
if (projectPath === null) {
138+
projectPath = dirname(filePath);
139+
}
140+
135141
const execOpts = {
136142
stream: 'stderr',
137143
allowEmptyStderr: true,
144+
cwd: projectPath,
138145
};
139146

140147
const output = await helpers.exec(this.execPath, args, execOpts);

0 commit comments

Comments
 (0)