Skip to content

Instantly share code, notes, and snippets.

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

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');
.option('-e, --environment <environment>', 'Environment to deploy to')
const file = `now.${program.environment}.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"


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

$ node deploy.js -e production
$ node deploy.js -e staging

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.