Skip to content

Instantly share code, notes, and snippets.

@captainsafia captainsafia/deploy.js
Last active Sep 16, 2017

Embed
What would you like to do?
A quick Node script to allow multi-environment deploys with now
#! /usr/bin/env node
'use strict';
const program = require('commander');
const fs = require('fs');
const { spawn } = require('child_process');
program
.version('1.0.0')
.option('-e, --environment <environment>', 'Environment to deploy to')
.parse(process.argv);
const file = `now.${program.environment}.json`;
fs.createReadStream(file).pipe(fs.createWriteStream('now.json'));
const deploy = spawn('now && now alias', { shell: true, stdio: 'inherit' });
deploy.on('close', () => fs.unlink('now.json', (error) => { if (error) throw error }));
{
"devDependencies": {
"commander": "latest"
}
}

Usage

This assumes that you have created now.${environment}.json configurations in your current directory.

$ node deploy.js -e production
$ node deploy.js -e staging
@9andresc

This comment has been minimized.

Copy link

commented Sep 14, 2017

Simple and so useful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.