Skip to content

Commit

Permalink
fix(publish): fix set alias to production deploy
Browse files Browse the repository at this point in the history
Migrate from now alias to now deploy --prod

BREAKING CHANGE: From now the deployments set auto alias with --prod option. Not use subcommand alias.
  • Loading branch information
lgaticaq committed Sep 23, 2019
1 parent 2949c6a commit ce0b5a6
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions src/publish.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
'use strict'

const path = require('path')
const execa = require('execa')
const { readJSON } = require('fs-extra')
const getError = require('./get-error')

module.exports = async (_, { cwd, env, stdout, stderr, logger }) => {
let deployOutput
const nowJson = await readJSON(path.resolve(cwd, 'now.json'))
try {
logger.log('Deploy app to now.sh')
const deployResult = execa(
'now',
['deploy', '--token', process.env.NOW_TOKEN],
['deploy', '--prod', '--token', process.env.NOW_TOKEN],
{ cwd, env }
)
deployResult.stdout.pipe(
Expand All @@ -23,30 +19,8 @@ module.exports = async (_, { cwd, env, stdout, stderr, logger }) => {
stderr,
{ end: false }
)
deployOutput = await deployResult
await deployResult
} catch (err) {
throw getError('ENOWDEPLOY')
}

if (nowJson.alias) {
try {
logger.log(`Assigning alias to deployment ${deployOutput.stdout}`)
const aliasResult = execa(
'now',
['alias', '--token', process.env.NOW_TOKEN],
{ cwd, env }
)
aliasResult.stdout.pipe(
stdout,
{ end: false }
)
aliasResult.stderr.pipe(
stderr,
{ end: false }
)
await aliasResult
} catch (err) {
throw getError('ENOWALIAS')
}
}
}

0 comments on commit ce0b5a6

Please sign in to comment.