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

Commit

Permalink
Merge pull request #109 from AtomLinter/arcanemagus/check-path
Browse files Browse the repository at this point in the history
Verify valid TextEditor and path
  • Loading branch information
Arcanemagus authored Oct 18, 2017
2 parents ec4a638 + ebf31dc commit d916068
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,29 @@ export default {
scope: 'file',
lintOnFly: true,
lint: (textEditor) => {
if (!atom.workspace.isTextEditor(textEditor)) {
return null;
}

const filePath = textEditor.getPath();
if (!filePath) {
// TextEditor has no path associated with it (yet)
return null;
}

const fileExt = path.extname(filePath);
if (fileExt === '.zsh' || fileExt === '.zsh-theme') {
// shellcheck does not support zsh
return [];
}

const text = textEditor.getText();
const cwd = path.dirname(filePath);
const showAll = this.enableNotice;
// The first -f parameter overrides any others
const parameters = [].concat(['-f', 'gcc'], this.userParameters, ['-']);
const options = { stdin: text, cwd, ignoreExitCode: true };

return helpers.exec(this.executablePath, parameters, options).then((output) => {
if (textEditor.getText() !== text) {
// The text has changed since the lint was triggered, tell Linter not to update
Expand Down

0 comments on commit d916068

Please sign in to comment.