Skip to content
This repository was archived by the owner on Mar 23, 2020. It is now read-only.
Open
Show file tree
Hide file tree
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
13 changes: 7 additions & 6 deletions lib/go-playground.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ existsSync = require('fs').existsSync
writeFile = require('fs').writeFile

module.exports =
configDefaults:
go_executable_path: '/usr/local/bin/go'
config:
go_executable_path:
type: 'string'
default: '/usr/local/bin/go'

activate: ->
atom.workspaceView.command "go-playground:execute", => @execute()
atom.commands.add 'atom-workspace', 'go-playground:execute': ->

execute: ->
editor = atom.workspace.getActiveEditor()
editor = atom.workspace.getActiveTextEditor()

# unsaved file returns undefined
current_file_path = editor.getPath()
return unless current_file_path
unless current_file_path.match(/\.go$/)
return console.log('The file extention is not matched.')

output_file_path = "#{atom.project.getPath()}/#{editor.getTitle()}.out"
output_file_path = "#{atom.project.getPaths()[0]}/#{editor.getTitle()}.out"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a better way to detect which project path belongs to active editor?


# evaluate go
command = atom.config.get('go-playground.go_executable_path')
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "go-playground",
"main": "./lib/go-playground",
"version": "0.0.2",
"version": "0.0.3",
"description": "Go run active file",
"activationEvents": [
"go-playground:execute"
],
"activationCommands": {
"atom-text-editor": ["go-playground:execute"]
},
"repository": "https://github.com/tachiba/atom-go-playground",
"license": "MIT",
"engines": {
Expand Down