From c115e023c658ece8645e53e1be2e9b0c08e7c93b Mon Sep 17 00:00:00 2001 From: alechp Date: Wed, 10 Jul 2019 12:27:38 -0700 Subject: [PATCH] fixed spread issue in pathsExistProm --- src/index.js | 26 +++++++++++++++++--------- src/utilities.js | 3 ++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index 36f2765..9fc57f2 100644 --- a/src/index.js +++ b/src/index.js @@ -3,19 +3,27 @@ import path from "path"; import { getWatcherConfig } from "./parser"; import { initWatcher } from "./watcher"; import { printLine, printMirror } from "tacker"; +import { pathsExistProm } from "./utilities"; export function init(cwd = process.env.configRootDir || process.cwd()) { let protatoPath = path.join(cwd, ".protato.js"); - let { config } = require(protatoPath); + pathsExistProm([protatoPath], ".protato.js config not found") + .then(resp => { + printMirror({ resp }, "magenta", "grey"); + let { config } = require(protatoPath); - printLine("blue"); - printMirror({ protatoPath }, "blue", "grey"); - printMirror({ config }, "blue", "grey"); - printLine("blue"); + printLine("blue"); + printMirror({ protatoPath }, "blue", "grey"); + printMirror({ config }, "blue", "grey"); + printLine("blue"); - let oWC = getWatcherConfig(config); - let hWatcher = initWatcher(oWC); - hWatcher.getDirectories(); + let oWC = getWatcherConfig(config); + let hWatcher = initWatcher(oWC); + hWatcher.getDirectories(); + }) + .catch(err => { + log(`init failed\n ${err}`); + }); } -// init(); +init(); diff --git a/src/utilities.js b/src/utilities.js index 292d7f4..74ed11f 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -9,10 +9,11 @@ export function pathsExistProm(arrPathsObj, szPreErrorMessage) { arrPathsObj.map(async pathToCheck => { await fs.access(pathToCheck); }); + resolve([true, ...arrPathsObj]); } else { await fs.access(arrPathsObj); + resolve([true, arrPathsObj]); } - resolve([true, ...arrPathsObj]); } catch (err) { reject(`${chalk.red(szPreErrorMessage)}: \n ${chalk.grey(err)}`); }