test(before) prevent config overwriting

This commit is contained in:
coderaiser 2016-11-09 12:19:52 +02:00
parent fe7d9baa38
commit 91c6396dac

View file

@ -1,14 +1,25 @@
'use strict';
const http = require('http');
const fs = require('fs');
const os = require('os');
const express = require('express');
const writejson = require('writejson');
const readjson = require('readjson');
const cloudcmd = require('..');
module.exports = (fn) => {
const pathConfig = os.homedir() + '/.cloudcmd.json';
const currentConfig = readjson.sync.try(pathConfig);
module.exports = (config, fn = config) => {
const app = express();
const server = http.createServer(app);
const after = () => {
if (currentConfig)
writejson.sync(pathConfig, currentConfig);
server.close();
};