{"action":"created","comment":{"url":"https://api.github.com/repos/monaca/monaca-cli/pulls/comments/50662446","id":50662446,"diff_hunk":"@@ -200,58 +205,70 @@\n         )\n         .then(\n           function() {\n-            // open the browser if no platform parameter is provided.\n-            if (!argv.platform) {\n-              var url = 'https://ide.monaca.mobi/project/' + projectInfo.projectId + '/' + (argv['build-type'] ? 'debugger' : 'build');\n-              monaca.getSessionUrl(url)\n-              .then(\n-                function(url) {\n-                  open(url);\n-                },\n-                function(error) {\n-                  util.err('Unable to open build page.');\n-                  process.exit(1);\n-                }\n-              );\n-            }\n-            else {\n-              // Build project on Monaca Cloud and download it into ./build folder.\n-              util.print(\"Building project on Monaca Cloud...\");\n-              monaca.buildProject(projectInfo.projectId, params).\n-              then(function(result) {\n-                if(result.binary_url) {\n-                  return result.binary_url;\n+            monaca.checkBuildAvailability(projectInfo.projectId, params.platform, params.purpose)\n+            .then(\n+              function() {\n+                // open the browser if no platform parameter is provided.\n+                if (!argv.platform) {\n+                  var url = 'https://ide.monaca.mobi/project/' + projectInfo.projectId + '/' + (argv['build-type'] ? 'debugger' : 'build');\n+                  monaca.getSessionUrl(url)\n+                  .then(\n+                    function(url) {\n+                      open(url);\n+                    },\n+                    function(error) {\n+                      util.err('Unable to open build page.');\n+                      process.exit(1);\n+                    }\n+                  );\n                 }\n                 else {\n-                  return Q.reject(result.error_message);\n-                }\n-              },\n-              function(err) {\n-                return Q.reject(err);\n-              },\n-              function (progress) {\n-                util.print(progress);\n-              })\n-              .then(\n-                function(url) {\n-                  monaca.getSessionUrl(url).then(\n-                    function(sessionUrl) {\n-                      var buildDir = \"\";\n-                      shell.mkdir('-p', path.join(cwd, 'build'));\n-                      monaca.download(sessionUrl, {}, function(response) {\n-                        var filename = \"\";\n-                        if (typeof response.headers['content-disposition'] === 'string') {\n-                          filename = response.headers['content-disposition'].match(/filename=\"?([^\"]+)\"?/)[1];\n-                        }\n-                        buildDir = path.join(cwd, \"build\", filename);\n-                        return buildDir;\n-                      }\n-                      ).then(\n-                        function(name) {\n-                          util.print(\"Your package is stored at \" + buildDir);\n+                  // Build project on Monaca Cloud and download it into ./build folder.\n+                  util.print(\"Building project on Monaca Cloud...\");\n+                  monaca.buildProject(projectInfo.projectId, params).\n+                  then(function(result) {","path":"src/remote.js","position":93,"original_position":93,"commit_id":"31e59c19ff3a46665a3b388ddf6aca121448fa84","original_commit_id":"31e59c19ff3a46665a3b388ddf6aca121448fa84","user":{"login":"andipavllo","id":10593912,"avatar_url":"https://avatars.githubusercontent.com/u/10593912?v=3","gravatar_id":"","url":"https://api.github.com/users/andipavllo","html_url":"https://github.com/andipavllo","followers_url":"https://api.github.com/users/andipavllo/followers","following_url":"https://api.github.com/users/andipavllo/following{/other_user}","gists_url":"https://api.github.com/users/andipavllo/gists{/gist_id}","starred_url":"https://api.github.com/users/andipavllo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andipavllo/subscriptions","organizations_url":"https://api.github.com/users/andipavllo/orgs","repos_url":"https://api.github.com/users/andipavllo/repos","events_url":"https://api.github.com/users/andipavllo/events{/privacy}","received_events_url":"https://api.github.com/users/andipavllo/received_events","type":"User","site_admin":false},"body":"This was already like this before.","created_at":"2016-01-25T08:04:04Z","updated_at":"2016-01-25T08:04:04Z","html_url":"https://github.com/monaca/monaca-cli/pull/41#discussion_r50662446","pull_request_url":"https://api.github.com/repos/monaca/monaca-cli/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/monaca/monaca-cli/pulls/comments/50662446"},"html":{"href":"https://github.com/monaca/monaca-cli/pull/41#discussion_r50662446"},"pull_request":{"href":"https://api.github.com/repos/monaca/monaca-cli/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/monaca/monaca-cli/pulls/41","id":57035881,"html_url":"https://github.com/monaca/monaca-cli/pull/41","diff_url":"https://github.com/monaca/monaca-cli/pull/41.diff","patch_url":"https://github.com/monaca/monaca-cli/pull/41.patch","issue_url":"https://api.github.com/repos/monaca/monaca-cli/issues/41","number":41,"state":"open","locked":false,"title":"Cli enhancement","user":{"login":"andipavllo","id":10593912,"avatar_url":"https://avatars.githubusercontent.com/u/10593912?v=3","gravatar_id":"","url":"https://api.github.com/users/andipavllo","html_url":"https://github.com/andipavllo","followers_url":"https://api.github.com/users/andipavllo/followers","following_url":"https://api.github.com/users/andipavllo/following{/other_user}","gists_url":"https://api.github.com/users/andipavllo/gists{/gist_id}","starred_url":"https://api.github.com/users/andipavllo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andipavllo/subscriptions","organizations_url":"https://api.github.com/users/andipavllo/orgs","repos_url":"https://api.github.com/users/andipavllo/repos","events_url":"https://api.github.com/users/andipavllo/events{/privacy}","received_events_url":"https://api.github.com/users/andipavllo/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-25T07:17:36Z","updated_at":"2016-01-25T08:04:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6543ce9641007d5bf3084d279338e2f993a7b509","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/monaca/monaca-cli/pulls/41/commits","review_comments_url":"https://api.github.com/repos/monaca/monaca-cli/pulls/41/comments","review_comment_url":"https://api.github.com/repos/monaca/monaca-cli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/monaca/monaca-cli/issues/41/comments","statuses_url":"https://api.github.com/repos/monaca/monaca-cli/statuses/31e59c19ff3a46665a3b388ddf6aca121448fa84","head":{"label":"monaca:cli-enhancement","ref":"cli-enhancement","sha":"31e59c19ff3a46665a3b388ddf6aca121448fa84","user":{"login":"monaca","id":1088627,"avatar_url":"https://avatars.githubusercontent.com/u/1088627?v=3","gravatar_id":"","url":"https://api.github.com/users/monaca","html_url":"https://github.com/monaca","followers_url":"https://api.github.com/users/monaca/followers","following_url":"https://api.github.com/users/monaca/following{/other_user}","gists_url":"https://api.github.com/users/monaca/gists{/gist_id}","starred_url":"https://api.github.com/users/monaca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monaca/subscriptions","organizations_url":"https://api.github.com/users/monaca/orgs","repos_url":"https://api.github.com/users/monaca/repos","events_url":"https://api.github.com/users/monaca/events{/privacy}","received_events_url":"https://api.github.com/users/monaca/received_events","type":"Organization","site_admin":false},"repo":{"id":26429801,"name":"monaca-cli","full_name":"monaca/monaca-cli","owner":{"login":"monaca","id":1088627,"avatar_url":"https://avatars.githubusercontent.com/u/1088627?v=3","gravatar_id":"","url":"https://api.github.com/users/monaca","html_url":"https://github.com/monaca","followers_url":"https://api.github.com/users/monaca/followers","following_url":"https://api.github.com/users/monaca/following{/other_user}","gists_url":"https://api.github.com/users/monaca/gists{/gist_id}","starred_url":"https://api.github.com/users/monaca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monaca/subscriptions","organizations_url":"https://api.github.com/users/monaca/orgs","repos_url":"https://api.github.com/users/monaca/repos","events_url":"https://api.github.com/users/monaca/events{/privacy}","received_events_url":"https://api.github.com/users/monaca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/monaca/monaca-cli","description":"Command line version of Monaca","fork":false,"url":"https://api.github.com/repos/monaca/monaca-cli","forks_url":"https://api.github.com/repos/monaca/monaca-cli/forks","keys_url":"https://api.github.com/repos/monaca/monaca-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monaca/monaca-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monaca/monaca-cli/teams","hooks_url":"https://api.github.com/repos/monaca/monaca-cli/hooks","issue_events_url":"https://api.github.com/repos/monaca/monaca-cli/issues/events{/number}","events_url":"https://api.github.com/repos/monaca/monaca-cli/events","assignees_url":"https://api.github.com/repos/monaca/monaca-cli/assignees{/user}","branches_url":"https://api.github.com/repos/monaca/monaca-cli/branches{/branch}","tags_url":"https://api.github.com/repos/monaca/monaca-cli/tags","blobs_url":"https://api.github.com/repos/monaca/monaca-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monaca/monaca-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monaca/monaca-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/monaca/monaca-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monaca/monaca-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/monaca/monaca-cli/languages","stargazers_url":"https://api.github.com/repos/monaca/monaca-cli/stargazers","contributors_url":"https://api.github.com/repos/monaca/monaca-cli/contributors","subscribers_url":"https://api.github.com/repos/monaca/monaca-cli/subscribers","subscription_url":"https://api.github.com/repos/monaca/monaca-cli/subscription","commits_url":"https://api.github.com/repos/monaca/monaca-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/monaca/monaca-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/monaca/monaca-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/monaca/monaca-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/monaca/monaca-cli/contents/{+path}","compare_url":"https://api.github.com/repos/monaca/monaca-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monaca/monaca-cli/merges","archive_url":"https://api.github.com/repos/monaca/monaca-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monaca/monaca-cli/downloads","issues_url":"https://api.github.com/repos/monaca/monaca-cli/issues{/number}","pulls_url":"https://api.github.com/repos/monaca/monaca-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/monaca/monaca-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/monaca/monaca-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monaca/monaca-cli/labels{/name}","releases_url":"https://api.github.com/repos/monaca/monaca-cli/releases{/id}","deployments_url":"https://api.github.com/repos/monaca/monaca-cli/deployments","created_at":"2014-11-10T09:27:49Z","updated_at":"2016-01-21T07:46:26Z","pushed_at":"2016-01-25T07:17:36Z","git_url":"git://github.com/monaca/monaca-cli.git","ssh_url":"git@github.com:monaca/monaca-cli.git","clone_url":"https://github.com/monaca/monaca-cli.git","svn_url":"https://github.com/monaca/monaca-cli","homepage":null,"size":6675,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"monaca:master","ref":"master","sha":"1cbe92d5c6f848d7caab1e361baa3d36c80b221b","user":{"login":"monaca","id":1088627,"avatar_url":"https://avatars.githubusercontent.com/u/1088627?v=3","gravatar_id":"","url":"https://api.github.com/users/monaca","html_url":"https://github.com/monaca","followers_url":"https://api.github.com/users/monaca/followers","following_url":"https://api.github.com/users/monaca/following{/other_user}","gists_url":"https://api.github.com/users/monaca/gists{/gist_id}","starred_url":"https://api.github.com/users/monaca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monaca/subscriptions","organizations_url":"https://api.github.com/users/monaca/orgs","repos_url":"https://api.github.com/users/monaca/repos","events_url":"https://api.github.com/users/monaca/events{/privacy}","received_events_url":"https://api.github.com/users/monaca/received_events","type":"Organization","site_admin":false},"repo":{"id":26429801,"name":"monaca-cli","full_name":"monaca/monaca-cli","owner":{"login":"monaca","id":1088627,"avatar_url":"https://avatars.githubusercontent.com/u/1088627?v=3","gravatar_id":"","url":"https://api.github.com/users/monaca","html_url":"https://github.com/monaca","followers_url":"https://api.github.com/users/monaca/followers","following_url":"https://api.github.com/users/monaca/following{/other_user}","gists_url":"https://api.github.com/users/monaca/gists{/gist_id}","starred_url":"https://api.github.com/users/monaca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monaca/subscriptions","organizations_url":"https://api.github.com/users/monaca/orgs","repos_url":"https://api.github.com/users/monaca/repos","events_url":"https://api.github.com/users/monaca/events{/privacy}","received_events_url":"https://api.github.com/users/monaca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/monaca/monaca-cli","description":"Command line version of Monaca","fork":false,"url":"https://api.github.com/repos/monaca/monaca-cli","forks_url":"https://api.github.com/repos/monaca/monaca-cli/forks","keys_url":"https://api.github.com/repos/monaca/monaca-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monaca/monaca-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monaca/monaca-cli/teams","hooks_url":"https://api.github.com/repos/monaca/monaca-cli/hooks","issue_events_url":"https://api.github.com/repos/monaca/monaca-cli/issues/events{/number}","events_url":"https://api.github.com/repos/monaca/monaca-cli/events","assignees_url":"https://api.github.com/repos/monaca/monaca-cli/assignees{/user}","branches_url":"https://api.github.com/repos/monaca/monaca-cli/branches{/branch}","tags_url":"https://api.github.com/repos/monaca/monaca-cli/tags","blobs_url":"https://api.github.com/repos/monaca/monaca-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monaca/monaca-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monaca/monaca-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/monaca/monaca-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monaca/monaca-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/monaca/monaca-cli/languages","stargazers_url":"https://api.github.com/repos/monaca/monaca-cli/stargazers","contributors_url":"https://api.github.com/repos/monaca/monaca-cli/contributors","subscribers_url":"https://api.github.com/repos/monaca/monaca-cli/subscribers","subscription_url":"https://api.github.com/repos/monaca/monaca-cli/subscription","commits_url":"https://api.github.com/repos/monaca/monaca-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/monaca/monaca-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/monaca/monaca-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/monaca/monaca-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/monaca/monaca-cli/contents/{+path}","compare_url":"https://api.github.com/repos/monaca/monaca-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monaca/monaca-cli/merges","archive_url":"https://api.github.com/repos/monaca/monaca-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monaca/monaca-cli/downloads","issues_url":"https://api.github.com/repos/monaca/monaca-cli/issues{/number}","pulls_url":"https://api.github.com/repos/monaca/monaca-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/monaca/monaca-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/monaca/monaca-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monaca/monaca-cli/labels{/name}","releases_url":"https://api.github.com/repos/monaca/monaca-cli/releases{/id}","deployments_url":"https://api.github.com/repos/monaca/monaca-cli/deployments","created_at":"2014-11-10T09:27:49Z","updated_at":"2016-01-21T07:46:26Z","pushed_at":"2016-01-25T07:17:36Z","git_url":"git://github.com/monaca/monaca-cli.git","ssh_url":"git@github.com:monaca/monaca-cli.git","clone_url":"https://github.com/monaca/monaca-cli.git","svn_url":"https://github.com/monaca/monaca-cli","homepage":null,"size":6675,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/monaca/monaca-cli/pulls/41"},"html":{"href":"https://github.com/monaca/monaca-cli/pull/41"},"issue":{"href":"https://api.github.com/repos/monaca/monaca-cli/issues/41"},"comments":{"href":"https://api.github.com/repos/monaca/monaca-cli/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/monaca/monaca-cli/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/monaca/monaca-cli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/monaca/monaca-cli/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/monaca/monaca-cli/statuses/31e59c19ff3a46665a3b388ddf6aca121448fa84"}}}}