Skip to content

Commit

Permalink
Removed old throw-first path checks, added PEX & cleaned up some cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
alechp committed Jul 31, 2019
1 parent f63f942 commit 6bca466
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/main.js.map

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"chokidar": "^3.0.1",
"fs-extra": "^8.0.1",
"is-empty": "^1.2.0",
"paths-exist": "^0.2.3",
"pkg-dir": "^4.2.0",
"tacker": "^0.1.1"
},
Expand Down
11 changes: 2 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import fs from "fs-extra";
import { getWatcherConfig } from "./parser";
import { initWatcher } from "./watcher";
import { printLine, printMirror } from "tacker";
import { pathsExistAsync } from "./utilities";
import chalk from "chalk";
import pathsExist from "paths-exist";

export async function init(
cwd = process.env.configRootDir || process.cwd(),
Expand All @@ -22,14 +21,8 @@ export async function init(
let protatoPath = path.resolve(cwd, ".protato.json");
printLine("cyan");
printMirror({ protatoPath }, "cyan", "grey");
//TODO: Change to fs.readJsonSync
// let { config } = require(protatoPath);
oConfig = await fs.readJson(protatoPath);
let pathInfo = await pathsExistAsync(
protatoPath,
".protato.json config not found"
);
let protatoPathFlag = pathInfo[0];
let protatoPathFlag = await pathsExist(protatoPath);
printMirror({ protatoPathFlag }, "cyan", "grey");
printLine("cyan");
}
Expand Down
23 changes: 11 additions & 12 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const log = console.log;
import path from "path";
import chalk from "chalk";
import { printLine, printMirror } from "tacker";
import { pathsExistSync } from "./utilities";

function PTOParser(config) {
const { parent, children } = config;
Expand Down Expand Up @@ -35,16 +34,10 @@ PTOParser.prototype.getWatcherTargets = function getWatcherTargets(
printMirror({ childDirPath }, "magenta", "grey");
printMirror({ childPackagePath }, "magenta", "grey");
printLine("magenta");
let pathsToCheck = [childDirPath, childPackagePath];

pathsExistSync(
pathsToCheck,
"getWatcherTargets' directory and package path check"
);
return { childDirPath, childPackagePath };
});
this.watcher.targets = targets;
if (this.watcher.targets !== undefined) {
if (typeof this.watcher.targets !== "undefined") {
printLine("yellow");
log(`${chalk.yellow("watcher targets")} are defined \n`);
printMirror({ targets }, "yellow", "grey");
Expand All @@ -61,12 +54,18 @@ PTOParser.prototype.getWatcherOptions = function getWatcherOptions() {
let childrenDirectoriesToIgnore = [];

function getChildNodeModulesPath(szChildTargetPath) {
if (typeof szChildTargetPath === "undefined") return null;
let potentialPath = path.join(szChildTargetPath, "node_modules");
pathsExistSync(
potentialPath,
"getWatcherOptions -> getChildNodeModulesPath() path check"
);
// pathsExistSync(
// potentialPath,
// "getWatcherOptions -> getChildNodeModulesPath() path check"
// );
return potentialPath;
// if (await pathsExist(potentialPath)) {
// return potentialPath;
// } else {
// return false;
// }
}

printLine("green");
Expand Down
4 changes: 0 additions & 4 deletions src/watcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chokidar from "chokidar";
import { pathsExistSync } from "./utilities";
import { printLine, printMirror } from "tacker";
import { linker } from "./linker";

Expand Down Expand Up @@ -28,7 +27,6 @@ const sampleConfig = {

export function PTOWatcher(oWatcherConfig) {
printMirror({ oWatcherConfig }, "blue", "grey");
pathsExistSync(oWatcherConfig.targets);
this.parent = oWatcherConfig.parent;
this.targets = oWatcherConfig.targets;
this.options = oWatcherConfig.options;
Expand All @@ -53,10 +51,8 @@ PTOWatcher.prototype.getDirectories = function getDirectories() {

PTOWatcher.prototype.createWatcher = function createWatcher() {
const { directoriesToWatch, options } = this;
pathsExistSync(directoriesToWatch);
printMirror({ directoriesToWatch }, "blue", "grey");
var watcher;
//TODO: Add a new sample repo to repogen
//TODO: Create backup config to test whether this works with 2+ directories
if (directoriesToWatch.length > 0) {
watcher = chokidar.watch(directoriesToWatch[0], { ...options });
Expand Down

0 comments on commit 6bca466

Please sign in to comment.