From 392638ff5a857678461bf88d4df566dbbbdb3a7e Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Fri, 4 Mar 2016 12:29:18 -0800 Subject: [PATCH] simplify cfg reading / merging --- lib/login.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/login.js b/lib/login.js index 6489408..9a17a59 100644 --- a/lib/login.js +++ b/lib/login.js @@ -1,9 +1,7 @@ -import { homedir } from 'os'; -import path from 'path'; -import fs from 'fs-promise'; +import chalk from 'chalk'; import fetch from 'node-fetch'; +import * as cfg from './cfg'; import { stringify as stringifyQuery } from 'querystring'; -import chalk from 'chalk'; const URL = 'http://api-registration.now.sh'; @@ -77,13 +75,6 @@ async function register () { } export default async function () { - const file = path.resolve(homedir(), '.now.json'); const loginData = await register(); - let existing = null; - try { - existing = await fs.readFile(file, 'utf8'); - existing = JSON.parse(existing); - } catch (err) {} - const config = Object.assign({}, existing, loginData); - return fs.writeFile(file, JSON.stringify(config)); + cfg.merge(loginData); }