mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
test(before) prevent config overwriting
This commit is contained in:
parent
fe7d9baa38
commit
91c6396dac
1 changed files with 12 additions and 1 deletions
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue