var fetch = require('node-fetch')
var execSync = require('child_process').execSync

var zapierHookURL = 'https://zapier.com/hooks/catch/3petdc/'
var tag = process.env.TRAVIS_TAG
  || execSync('git describe --abbrev=0 --tags').toString().trim()

fetch(zapierHookURL, {
  method: 'POST',
  body: JSON.stringify({
    tweet: `date-fns ${tag} is published! See changelog: https://github.com/toptal/tracker-front/blob/master/CHANGELOG.md#${tag.replace(/\./g, '')}`
  }),
  headers: {'Content-Type': 'application/json'}
})

import fetch from 'node-fetch'
import {execSync} from 'child_process'

const zapierHookURL
  = `https://zapier.com/hooks/catch/${process.env.ZAPIER_TWEET_RELEASE_HOOK_ID}/`
const tag = process.env.TRAVIS_TAG
  || execSync('git describe --abbrev=0 --tags').toString().trim()
const changelogUrl
  = `https://github.com/toptal/tracker-front/blob/master/CHANGELOG.md#${tag.replace(/\./g, '')}`

console.log('~ Posting release tweet')

fetch(zapierHookURL, {
  method: 'POST',
  body: JSON.stringify({
    tweet: `date-fns ${tag} is published! See changelog: ${changelogUrl}.`
  }),
  headers: {'Content-Type': 'application/json'}
})
  .then(() => console.log('+ Done!'))
  .catch((err) => {
    console.error(err)
    process.exit(1)
  })

Secure the Zapier hook URL, use ES 2015 in the script
Secure the Zapier hook URL, use ES 2015 in the script
