UNPKG

gcloud-deploy

Version:

Quickly deploy a Node.js project on Google Compute Engine

35 lines (29 loc) 942 B
#!/usr/bin/env node 'use strict' var through = require('through2') var deployStream = require('./')() deployStream .on('error', function (err) { if (err.code === 403) { console.error(new Error('Authentication failed. Did you provide a `keyFile` or `credentials` object?')) } else { console.error(err) } }) .on('file', function (file) { console.log('Backup created:', file.bucket.name + '/' + file.name) }) .on('vm', function (vm) { console.log('VM ready:', vm.name) }) .on('start', function (url) { console.log('Deployed successfully!', url) }) .pipe(through(function (logLine, enc, next) { var vm = deployStream.vm var url = deployStream.url // replace some verbosity with what's probably more helpful-- the IP logLine = String(logLine).replace(new RegExp(vm.name + '[^:]*', 'g'), '(' + url + ')').trim() next(null, '\n' + logLine) })) .pipe(process.stdout)