Skip to content

Commit

Permalink
Add this.logJson to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidWells committed Jul 23, 2019
1 parent 5905ad6 commit 0a684c8
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class DeployCommand extends Command {
configPath = site.configPath
pathInfo['Configuration path'] = configPath
}
log(prettyjson.render(pathInfo), this, flags)
this.log(prettyjson.render(pathInfo))

ensureDirectory(deployFolder, this.exit)

Expand All @@ -117,9 +117,9 @@ class DeployCommand extends Command {
let results
try {
if (deployToProduction) {
log('Deploying to live site URL...', this, flags)
this.log('Deploying to live site URL...')
} else {
log('Deploying to draft URL...', this, flags)
this.log('Deploying to draft URL...')
}

results = await api.deploy(siteId, deployFolder, {
Expand Down Expand Up @@ -173,14 +173,14 @@ class DeployCommand extends Command {
msgData['Live Draft URL'] = deployUrl
}

log('', this, flags)
// Spacer
this.log()

// Json response for piping commands
if (flags.json && results) {

const jsonData = {
name: results.deploy.deployId,
// site_id: results.deploy.deployId,
site_id: results.deploy.site_id,
deploy_id: results.deployId,
deploy_url: deployUrl,
logs: logsUrl,
Expand All @@ -189,17 +189,17 @@ class DeployCommand extends Command {
jsonData.url = siteUrl
}

this.log(JSON.stringify(jsonData, null, 2))
this.logJson(jsonData)
return false
}

this.log(prettyjson.render(msgData))

if (!deployToProduction) {
console.log()
console.log('If everything looks good on your draft URL, take it live with the --prod flag.')
console.log(`${chalk.cyanBright.bold('netlify deploy --prod')}`)
console.log()
this.log()
this.log('If everything looks good on your draft URL, take it live with the --prod flag.')
this.log(`${chalk.cyanBright.bold('netlify deploy --prod')}`)
this.log()
}

if (flags['open']) {
Expand All @@ -210,13 +210,6 @@ class DeployCommand extends Command {
}
}

// Hide logs if --json flag used
function log(message, context, flags) {
if (!flags.json) {
context.log(message)
}
}

DeployCommand.description = `Create a new deploy from the contents of a folder
Deploys from the build settings found in the netlify.toml file, or settings from the API.
Expand Down

0 comments on commit 0a684c8

Please sign in to comment.