From da709343c44a39673f5203e9e526cfdd8581196c Mon Sep 17 00:00:00 2001
From: Pavel Zastavnitskiy <pasha.zastavnitskiy@gmail.com>
Date: Sun, 9 Jun 2019 22:47:39 +0200
Subject: [PATCH] fix: Don't show broken url if site is undeployed.

Show status and /deploys url instead.
---
 src/commands/sites/list.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/commands/sites/list.js b/src/commands/sites/list.js
index 441ad78c88b..6215049d2cd 100644
--- a/src/commands/sites/list.js
+++ b/src/commands/sites/list.js
@@ -19,7 +19,9 @@ class SitesListCommand extends Command {
           id: site.id,
           name: site.name,
           ssl_url: site.ssl_url,
-          account_name: site.account_name
+          account_name: site.account_name,
+          published_deploy: site.published_deploy,
+          admin_url: site.admin_url
         }
 
         if (site.build_settings && site.build_settings.repo_url) {
@@ -49,7 +51,13 @@ class SitesListCommand extends Command {
 
       logSites.forEach(s => {
         console.log(`${chalk.greenBright(s.name)} - ${s.id}`)
-        console.log(`  ${chalk.whiteBright.bold('url:')}  ${chalk.yellowBright(s.ssl_url)}`)
+
+        if (s.published_deploy) {
+          console.log(`  ${chalk.whiteBright.bold('url:')}  ${chalk.yellowBright(s.ssl_url)}`)
+        } else {
+          console.log(`  ${chalk.whiteBright.bold('url:')}  ${chalk.redBright('Site deploy failed')} (${s.admin_url}/deploys)`)
+        }
+
         if (s.repo_url) {
           console.log(`  ${chalk.whiteBright.bold('repo:')} ${chalk.white(s.repo_url)}`)
         }