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
#! /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
Simple and so useful. Thanks!