Browse Source

move to files

karl.hudgell 4 years ago
parent
commit
0dbdc924a6
3 changed files with 13 additions and 14 deletions
  1. 0 12
      lib/common.js
  2. 11 1
      lib/files.js
  3. 2 1
      pages/pages.js

+ 0 - 12
lib/common.js

@@ -1,22 +1,10 @@
 const chalk = require('chalk');
 const clear = require('clear');
 const figlet = require('figlet');
-const pathExists = require('path-exists');
 const fs = require('fs')
-const path = require("path");
 
 
 module.exports = {
-    writeIpAddress: (value) => {
-        const data = {
-            ipAddress: value
-        }
-        try {
-            fs.writeFileSync('./data/MiWatch.json', JSON.stringify(data))
-        } catch (err) {
-            console.log(err)
-        }
-    },
     header: (page) => {
         clear();
         console.log(

+ 11 - 1
lib/files.js

@@ -8,5 +8,15 @@ module.exports = {
 
   directoryExists: (filePath) => {
     return fs.existsSync(filePath);
-  }
+  },
+  writeIpAddress: (value) => {
+    const data = {
+      ipAddress: value
+    }
+    try {
+      fs.writeFileSync('./data/MiWatch.json', JSON.stringify(data))
+    } catch (err) {
+      console.log(err)
+    }
+  },
 };

+ 2 - 1
pages/pages.js

@@ -2,6 +2,7 @@ const chalk = require('chalk');
 const common = require('../lib/common');
 const inquirer = require('../lib/inquirer');
 const shellExec = require('shell-exec')
+const files = require('../lib/files')
 
 
 module.exports = {
@@ -24,7 +25,7 @@ module.exports = {
                 module.exports.connectWifi()
             } else {
                 console.log(chalk.green('MiWatch Connected'))
-                common.writeIpAddress(miWatchIpaddress)
+                files.writeIpAddress(miWatchIpaddress)
                 await common.pause(3000)
                 module.exports.mainMenu()
             }