{"action":"created","comment":{"url":"https://api.github.com/repos/rgbkrk/atom-script/pulls/comments/56891047","id":56891047,"diff_hunk":"@@ -95,21 +101,24 @@ class Runner\n       arg = arg.replace(/{FILE_ACTIVE_NAME_BASE}/g, path.join(codeContext.filename, '..'))\n     if project_path?\n       arg = arg.replace(/{PROJECT_PATH}/g, project_path)\n-    \n+\n     arg\n \n   args: (codeContext, extraArgs) ->\n     args = (@scriptOptions.cmdArgs.concat extraArgs).concat @scriptOptions.scriptArgs\n-    project_path = ''\n-    paths = atom.project.getPaths()\n-    if paths.length > 0\n-      fs.stat(paths[0], (err, stats) ->\n-        if !err\n-          project_path = if stats.isDirectory() then paths[0] else path.join(paths[0], '..')\n-      )\n-    \n+    project_path = @getProjectPath or ''\n     args = (@fillVarsInArg arg, codeContext, project_path for arg in args)\n-    \n+\n     if not @scriptOptions.cmd? or @scriptOptions.cmd is ''\n       args = codeContext.shebangCommandArgs().concat args\n     args\n+\n+  getProjectPath: ->","path":"lib/runner.coffee","position":48,"original_position":48,"commit_id":"629040b3af6d35d0f9333916056a08cdb5843101","original_commit_id":"629040b3af6d35d0f9333916056a08cdb5843101","user":{"login":"nixel2007","id":1132840,"avatar_url":"https://avatars.githubusercontent.com/u/1132840?v=3","gravatar_id":"","url":"https://api.github.com/users/nixel2007","html_url":"https://github.com/nixel2007","followers_url":"https://api.github.com/users/nixel2007/followers","following_url":"https://api.github.com/users/nixel2007/following{/other_user}","gists_url":"https://api.github.com/users/nixel2007/gists{/gist_id}","starred_url":"https://api.github.com/users/nixel2007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nixel2007/subscriptions","organizations_url":"https://api.github.com/users/nixel2007/orgs","repos_url":"https://api.github.com/users/nixel2007/repos","events_url":"https://api.github.com/users/nixel2007/events{/privacy}","received_events_url":"https://api.github.com/users/nixel2007/received_events","type":"User","site_admin":false},"body":"Also, this projectPath is used to `replacements` section (to fill built-in variables).\r\nI think, you need to check the settings, like you did in L55","created_at":"2016-03-21T20:29:15Z","updated_at":"2016-03-21T20:29:15Z","html_url":"https://github.com/rgbkrk/atom-script/pull/850#discussion_r56891047","pull_request_url":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850","_links":{"self":{"href":"https://api.github.com/repos/rgbkrk/atom-script/pulls/comments/56891047"},"html":{"href":"https://github.com/rgbkrk/atom-script/pull/850#discussion_r56891047"},"pull_request":{"href":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850"}}},"pull_request":{"url":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850","id":63424555,"html_url":"https://github.com/rgbkrk/atom-script/pull/850","diff_url":"https://github.com/rgbkrk/atom-script/pull/850.diff","patch_url":"https://github.com/rgbkrk/atom-script/pull/850.patch","issue_url":"https://api.github.com/repos/rgbkrk/atom-script/issues/850","number":850,"state":"open","locked":false,"title":"Add ability to change CWD behavior","user":{"login":"avonmoll","id":4260850,"avatar_url":"https://avatars.githubusercontent.com/u/4260850?v=3","gravatar_id":"","url":"https://api.github.com/users/avonmoll","html_url":"https://github.com/avonmoll","followers_url":"https://api.github.com/users/avonmoll/followers","following_url":"https://api.github.com/users/avonmoll/following{/other_user}","gists_url":"https://api.github.com/users/avonmoll/gists{/gist_id}","starred_url":"https://api.github.com/users/avonmoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avonmoll/subscriptions","organizations_url":"https://api.github.com/users/avonmoll/orgs","repos_url":"https://api.github.com/users/avonmoll/repos","events_url":"https://api.github.com/users/avonmoll/events{/privacy}","received_events_url":"https://api.github.com/users/avonmoll/received_events","type":"User","site_admin":false},"body":"I've been wanting `script` to \"track\" with whatever file I have open (may have multiple projects open). Basically, `script`'s default behavior of using the first project directory as CWD was not meeting my needs. I found that there is interest in extending this capability from others as well (ref: #248, #543), so I decided to try my hand at it.\r\n\r\n`script` gets a new setting for __'Default CWD Behavior'__ which is an enum with three string options:\r\n\r\n1. First project directory - If there is a project directory open it uses the first path\r\n2. Project directory of the script- Uses helper method to determine the project directory for the active editor (if there is one)\r\n3. Directory of the script - This is __my__ desired behavior which is to set CWD to the directory of the active editor\r\n\r\nNote: For the config I wanted to use the `enum` options demonstrated in https://atom.io/docs/api/v1.6.0/Config:\r\n\r\n> ```\r\nconfig:\r\n  someSetting:\r\n    type: 'string'\r\n    default: 'foo'\r\n    enum: [\r\n      {value: 'foo', description: 'Foo mode. You want this.'}\r\n      {value: 'bar', description: 'Bar mode. Nobody wants that!'}\r\n    ]\r\n```\r\n\r\nbut for some reason, when I tried this, the items in the Settings' drop-down menu were blank/invisible (although they worked properly in terms of operation).\r\n\r\n__Tested on Windows only!__","created_at":"2016-03-18T19:26:30Z","updated_at":"2016-03-21T20:29:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02a2962915fb1f0ecdcadcc40a5784113c775530","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850/commits","review_comments_url":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850/comments","review_comment_url":"https://api.github.com/repos/rgbkrk/atom-script/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rgbkrk/atom-script/issues/850/comments","statuses_url":"https://api.github.com/repos/rgbkrk/atom-script/statuses/629040b3af6d35d0f9333916056a08cdb5843101","head":{"label":"avonmoll:master","ref":"master","sha":"629040b3af6d35d0f9333916056a08cdb5843101","user":{"login":"avonmoll","id":4260850,"avatar_url":"https://avatars.githubusercontent.com/u/4260850?v=3","gravatar_id":"","url":"https://api.github.com/users/avonmoll","html_url":"https://github.com/avonmoll","followers_url":"https://api.github.com/users/avonmoll/followers","following_url":"https://api.github.com/users/avonmoll/following{/other_user}","gists_url":"https://api.github.com/users/avonmoll/gists{/gist_id}","starred_url":"https://api.github.com/users/avonmoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avonmoll/subscriptions","organizations_url":"https://api.github.com/users/avonmoll/orgs","repos_url":"https://api.github.com/users/avonmoll/repos","events_url":"https://api.github.com/users/avonmoll/events{/privacy}","received_events_url":"https://api.github.com/users/avonmoll/received_events","type":"User","site_admin":false},"repo":{"id":54149604,"name":"atom-script","full_name":"avonmoll/atom-script","owner":{"login":"avonmoll","id":4260850,"avatar_url":"https://avatars.githubusercontent.com/u/4260850?v=3","gravatar_id":"","url":"https://api.github.com/users/avonmoll","html_url":"https://github.com/avonmoll","followers_url":"https://api.github.com/users/avonmoll/followers","following_url":"https://api.github.com/users/avonmoll/following{/other_user}","gists_url":"https://api.github.com/users/avonmoll/gists{/gist_id}","starred_url":"https://api.github.com/users/avonmoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avonmoll/subscriptions","organizations_url":"https://api.github.com/users/avonmoll/orgs","repos_url":"https://api.github.com/users/avonmoll/repos","events_url":"https://api.github.com/users/avonmoll/events{/privacy}","received_events_url":"https://api.github.com/users/avonmoll/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/avonmoll/atom-script","description":":runner: Run ( scripts | selections | source ) in Atom","fork":true,"url":"https://api.github.com/repos/avonmoll/atom-script","forks_url":"https://api.github.com/repos/avonmoll/atom-script/forks","keys_url":"https://api.github.com/repos/avonmoll/atom-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avonmoll/atom-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avonmoll/atom-script/teams","hooks_url":"https://api.github.com/repos/avonmoll/atom-script/hooks","issue_events_url":"https://api.github.com/repos/avonmoll/atom-script/issues/events{/number}","events_url":"https://api.github.com/repos/avonmoll/atom-script/events","assignees_url":"https://api.github.com/repos/avonmoll/atom-script/assignees{/user}","branches_url":"https://api.github.com/repos/avonmoll/atom-script/branches{/branch}","tags_url":"https://api.github.com/repos/avonmoll/atom-script/tags","blobs_url":"https://api.github.com/repos/avonmoll/atom-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avonmoll/atom-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avonmoll/atom-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/avonmoll/atom-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avonmoll/atom-script/statuses/{sha}","languages_url":"https://api.github.com/repos/avonmoll/atom-script/languages","stargazers_url":"https://api.github.com/repos/avonmoll/atom-script/stargazers","contributors_url":"https://api.github.com/repos/avonmoll/atom-script/contributors","subscribers_url":"https://api.github.com/repos/avonmoll/atom-script/subscribers","subscription_url":"https://api.github.com/repos/avonmoll/atom-script/subscription","commits_url":"https://api.github.com/repos/avonmoll/atom-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/avonmoll/atom-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/avonmoll/atom-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/avonmoll/atom-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/avonmoll/atom-script/contents/{+path}","compare_url":"https://api.github.com/repos/avonmoll/atom-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avonmoll/atom-script/merges","archive_url":"https://api.github.com/repos/avonmoll/atom-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avonmoll/atom-script/downloads","issues_url":"https://api.github.com/repos/avonmoll/atom-script/issues{/number}","pulls_url":"https://api.github.com/repos/avonmoll/atom-script/pulls{/number}","milestones_url":"https://api.github.com/repos/avonmoll/atom-script/milestones{/number}","notifications_url":"https://api.github.com/repos/avonmoll/atom-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avonmoll/atom-script/labels{/name}","releases_url":"https://api.github.com/repos/avonmoll/atom-script/releases{/id}","deployments_url":"https://api.github.com/repos/avonmoll/atom-script/deployments","created_at":"2016-03-17T20:35:06Z","updated_at":"2016-03-17T20:35:08Z","pushed_at":"2016-03-18T19:08:37Z","git_url":"git://github.com/avonmoll/atom-script.git","ssh_url":"git@github.com:avonmoll/atom-script.git","clone_url":"https://github.com/avonmoll/atom-script.git","svn_url":"https://github.com/avonmoll/atom-script","homepage":"https://atom.io/packages/script","size":671,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rgbkrk:master","ref":"master","sha":"d93942887ca5d6bdd5da13275cd90b116112a5a9","user":{"login":"rgbkrk","id":836375,"avatar_url":"https://avatars.githubusercontent.com/u/836375?v=3","gravatar_id":"","url":"https://api.github.com/users/rgbkrk","html_url":"https://github.com/rgbkrk","followers_url":"https://api.github.com/users/rgbkrk/followers","following_url":"https://api.github.com/users/rgbkrk/following{/other_user}","gists_url":"https://api.github.com/users/rgbkrk/gists{/gist_id}","starred_url":"https://api.github.com/users/rgbkrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgbkrk/subscriptions","organizations_url":"https://api.github.com/users/rgbkrk/orgs","repos_url":"https://api.github.com/users/rgbkrk/repos","events_url":"https://api.github.com/users/rgbkrk/events{/privacy}","received_events_url":"https://api.github.com/users/rgbkrk/received_events","type":"User","site_admin":false},"repo":{"id":17310099,"name":"atom-script","full_name":"rgbkrk/atom-script","owner":{"login":"rgbkrk","id":836375,"avatar_url":"https://avatars.githubusercontent.com/u/836375?v=3","gravatar_id":"","url":"https://api.github.com/users/rgbkrk","html_url":"https://github.com/rgbkrk","followers_url":"https://api.github.com/users/rgbkrk/followers","following_url":"https://api.github.com/users/rgbkrk/following{/other_user}","gists_url":"https://api.github.com/users/rgbkrk/gists{/gist_id}","starred_url":"https://api.github.com/users/rgbkrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgbkrk/subscriptions","organizations_url":"https://api.github.com/users/rgbkrk/orgs","repos_url":"https://api.github.com/users/rgbkrk/repos","events_url":"https://api.github.com/users/rgbkrk/events{/privacy}","received_events_url":"https://api.github.com/users/rgbkrk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rgbkrk/atom-script","description":":runner: Run ( scripts | selections | source ) in Atom","fork":false,"url":"https://api.github.com/repos/rgbkrk/atom-script","forks_url":"https://api.github.com/repos/rgbkrk/atom-script/forks","keys_url":"https://api.github.com/repos/rgbkrk/atom-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rgbkrk/atom-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rgbkrk/atom-script/teams","hooks_url":"https://api.github.com/repos/rgbkrk/atom-script/hooks","issue_events_url":"https://api.github.com/repos/rgbkrk/atom-script/issues/events{/number}","events_url":"https://api.github.com/repos/rgbkrk/atom-script/events","assignees_url":"https://api.github.com/repos/rgbkrk/atom-script/assignees{/user}","branches_url":"https://api.github.com/repos/rgbkrk/atom-script/branches{/branch}","tags_url":"https://api.github.com/repos/rgbkrk/atom-script/tags","blobs_url":"https://api.github.com/repos/rgbkrk/atom-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rgbkrk/atom-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rgbkrk/atom-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/rgbkrk/atom-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rgbkrk/atom-script/statuses/{sha}","languages_url":"https://api.github.com/repos/rgbkrk/atom-script/languages","stargazers_url":"https://api.github.com/repos/rgbkrk/atom-script/stargazers","contributors_url":"https://api.github.com/repos/rgbkrk/atom-script/contributors","subscribers_url":"https://api.github.com/repos/rgbkrk/atom-script/subscribers","subscription_url":"https://api.github.com/repos/rgbkrk/atom-script/subscription","commits_url":"https://api.github.com/repos/rgbkrk/atom-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/rgbkrk/atom-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/rgbkrk/atom-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/rgbkrk/atom-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/rgbkrk/atom-script/contents/{+path}","compare_url":"https://api.github.com/repos/rgbkrk/atom-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rgbkrk/atom-script/merges","archive_url":"https://api.github.com/repos/rgbkrk/atom-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rgbkrk/atom-script/downloads","issues_url":"https://api.github.com/repos/rgbkrk/atom-script/issues{/number}","pulls_url":"https://api.github.com/repos/rgbkrk/atom-script/pulls{/number}","milestones_url":"https://api.github.com/repos/rgbkrk/atom-script/milestones{/number}","notifications_url":"https://api.github.com/repos/rgbkrk/atom-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rgbkrk/atom-script/labels{/name}","releases_url":"https://api.github.com/repos/rgbkrk/atom-script/releases{/id}","deployments_url":"https://api.github.com/repos/rgbkrk/atom-script/deployments","created_at":"2014-03-01T07:18:08Z","updated_at":"2016-03-21T03:31:40Z","pushed_at":"2016-03-21T07:39:16Z","git_url":"git://github.com/rgbkrk/atom-script.git","ssh_url":"git@github.com:rgbkrk/atom-script.git","clone_url":"https://github.com/rgbkrk/atom-script.git","svn_url":"https://github.com/rgbkrk/atom-script","homepage":"https://atom.io/packages/script","size":1237,"stargazers_count":350,"watchers_count":350,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":129,"mirror_url":null,"open_issues_count":244,"forks":129,"open_issues":244,"watchers":350,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850"},"html":{"href":"https://github.com/rgbkrk/atom-script/pull/850"},"issue":{"href":"https://api.github.com/repos/rgbkrk/atom-script/issues/850"},"comments":{"href":"https://api.github.com/repos/rgbkrk/atom-script/issues/850/comments"},"review_comments":{"href":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850/comments"},"review_comment":{"href":"https://api.github.com/repos/rgbkrk/atom-script/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rgbkrk/atom-script/pulls/850/commits"},"statuses":{"href":"https://api.github.com/repos/rgbkrk/atom-script/statuses/629040b3af6d35d0f9333916056a08cdb5843101"}}}}