diff --git a/CHANGELOG.md b/CHANGELOG.md index 6410963..66d6899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Next +- Improve command not found error message - Add goimports beautifier for Go language -- ... - Fixes [#1728](https://github.com/Glavin001/atom-beautify/issues/1728). Remove Shell-Env from Executable, use Atom's process.env instead. See [#1735](https://github.com/Glavin001/atom-beautify/pull/1735). +- ... # v0.30.2 (2017-06-20) - Fixes [#1030](https://github.com/Glavin001/atom-beautify/issues/1030). Add support for alpha versions of autopep8 diff --git a/spec/atom-beautify-spec.coffee b/spec/atom-beautify-spec.coffee index 3ad936f..1cc812d 100644 --- a/spec/atom-beautify-spec.coffee +++ b/spec/atom-beautify-spec.coffee @@ -78,8 +78,11 @@ describe "Atom-Beautify", -> expect(v).not.toBe(null) expect(v instanceof Error).toBe(true) expect(v.code).toBe("CommandNotFound") - expect(v.description).toBe(undefined, \ - 'Error should not have a description.') + expect(typeof v.description).toBe("string", \ + 'Error should have a description.') + expect(v.description + .indexOf("Executable - Beautifier - Path")).toBe(-1, \ + "Error should not have pathOption.") return v p.then(cb, cb) return p diff --git a/src/beautifiers/beautifier.coffee b/src/beautifiers/beautifier.coffee index dce486a..29f82ab 100644 --- a/src/beautifiers/beautifier.coffee +++ b/src/beautifiers/beautifier.coffee @@ -187,6 +187,11 @@ module.exports = class Beautifier installation: @link cmd: executable }) + help ?= { + program: executable + link: @link + pathOption: undefined + } exe.run(args, {cwd, ignoreReturnCode, help, onStdin}) ### diff --git a/src/beautifiers/executable.coffee b/src/beautifiers/executable.coffee index e235179..61f42b3 100644 --- a/src/beautifiers/executable.coffee +++ b/src/beautifiers/executable.coffee @@ -134,6 +134,11 @@ class Executable { cmd, cwd, ignoreReturnCode, help, onStdin, returnStderr, returnStdoutOrStderr } = options exeName = cmd or @cmd cwd ?= os.tmpDir() + help ?= { + program: @cmd + link: @installation or @homepage + pathOption: "Executable - #{@name or @cmd} - Path" + } # Resolve executable and all args Promise.all([@shellEnv(), this.resolveArgs(args)]) @@ -276,45 +281,22 @@ class Executable if help? if typeof help is "object" # Basic notice - helpStr = "See #{help.link} for program \ - installation instructions.\n" - # Help to configure Atom Beautify for program's path + docsLink = "https://github.com/Glavin001/atom-beautify#beautifiers" + helpStr = "See #{exe} installation instructions at #{docsLink}#{if help.link then (' or go to '+help.link) else ''}\n" + # # Help to configure Atom Beautify for program's path helpStr += "You can configure Atom Beautify \ with the absolute path \ to '#{help.program or exe}' by setting \ '#{help.pathOption}' in \ the Atom Beautify package settings.\n" if help.pathOption - # Optional, additional help - helpStr += help.additional if help.additional - # Common Help - issueSearchLink = - "https://github.com/Glavin001/atom-beautify/\ - search?q=#{exe}&type=Issues" - docsLink = "https://github.com/Glavin001/\ - atom-beautify/tree/master/docs" helpStr += "Your program is properly installed if running \ '#{if @isWindows() then 'where.exe' \ else 'which'} #{exe}' \ in your #{if @isWindows() then 'CMD prompt' \ else 'Terminal'} \ - returns an absolute path to the executable. \ - If this does not work then you have not \ - installed the program correctly and so \ - Atom Beautify will not find the program. \ - Atom Beautify requires that the program be \ - found in your PATH environment variable. \n\ - Note that this is not an Atom Beautify issue \ - if beautification does not work and the above \ - command also does not work: this is expected \ - behaviour, since you have not properly installed \ - your program. Please properly setup the program \ - and search through existing Atom Beautify issues \ - before creating a new issue. \ - See #{issueSearchLink} for related Issues and \ - #{docsLink} for documentation. \ - If you are still unable to resolve this issue on \ - your own then please create a new issue and \ - ask for help.\n" + returns an absolute path to the executable.\n" + # # Optional, additional help + helpStr += help.additional if help.additional er.description = helpStr else #if typeof help is "string" er.description = help