From 8973a6d777d368b54dfaf6a0bf46ad0189d3bcce Mon Sep 17 00:00:00 2001 From: probablycorey Date: Wed, 22 Jan 2014 13:51:51 -0800 Subject: [PATCH] Display dialog error when commands can't be installed --- src/command-installer.coffee | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/command-installer.coffee b/src/command-installer.coffee index e085dd2f2..4617c6d3c 100644 --- a/src/command-installer.coffee +++ b/src/command-installer.coffee @@ -26,27 +26,33 @@ module.exports = getInstallDirectory: -> "/usr/local/bin" - install: (commandPath, callback) -> + install: (commandPath) -> commandName = path.basename(commandPath, path.extname(commandPath)) - directory = @getInstallDirectory() if fs.existsSync(directory) destinationPath = path.join(directory, commandName) - unlinkCommand destinationPath, (error) -> - return callback(error) if error? - symlinkCommand commandPath, destinationPath, (error) -> callback(error) + unlinkCommand destinationPath, (error) => + if error? + @displayError(error, commandPath) + else + symlinkCommand commandPath, destinationPath, (error) => + @displayError(error, commandPath) if error else error = new Error("No destination directory exists to install") - callback(error) + @displayError(error, commandPath) if error + + displayError: (error, commandPath) -> + atom.confirm + type: 'warning' + message: "Failed to install `#{commandPath}` binary" + detailedMessage: "#{error.message}\n\nRun 'sudo ln -s #{commandPath} #{path.join(@getInstallDirectory(), path.basename(commandPath))}' to install." installAtomCommand: -> resourcePath = atom.getLoadSettings().resourcePath commandPath = path.join(resourcePath, 'atom.sh') - @install commandPath, (error) -> - console.warn "Failed to install `#{commandPath}` binary", error if error? + @install commandPath installApmCommand: -> resourcePath = atom.getLoadSettings().resourcePath commandPath = path.join(resourcePath, 'apm', 'node_modules', '.bin', 'apm') - @install commandPath, (error) -> - console.warn "Failed to install `#{commandPath}` binary", error if error? + @install commandPath