Skip to content

Commit

Permalink
fix(scaffold): migrated to findup-sync to find the project root
Browse files Browse the repository at this point in the history
migrated to use find-up sync to determine project root, removed additional packages
  • Loading branch information
anshumanv committed Mar 25, 2019
1 parent 37eb051 commit 9ad3c15
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 81 deletions.
8 changes: 8 additions & 0 deletions packages/utils/find-root.ts
@@ -0,0 +1,8 @@
import * as findup from "findup-sync";
import * as path from "path";

export function findProjectRoot(curDir: string): string {
const rootFilePath = findup(`package.json`);
const projectRoot = path.dirname(rootFilePath);
return projectRoot;
}
94 changes: 23 additions & 71 deletions packages/utils/package-lock.json

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

1 change: 0 additions & 1 deletion packages/utils/package.json
Expand Up @@ -18,7 +18,6 @@
"jscodeshift": "^0.5.1",
"log-symbols": "^2.2.0",
"p-each-series": "^1.0.0",
"pkg-dir": "^4.0.0",
"prettier": "^1.15.2",
"yeoman-environment": "^2.3.4",
"yeoman-generator": "^3.1.1"
Expand Down
17 changes: 8 additions & 9 deletions packages/utils/scaffold.ts
Expand Up @@ -2,7 +2,7 @@ import chalk from "chalk";
import * as j from "jscodeshift";
import pEachSeries = require("p-each-series");
import * as path from "path";
import pkgDir from "pkg-dir";
import { findProjectRoot } from "./find-root";

import { IError } from "../init/types";
import { IConfig, ITransformConfig } from "./modify-config-helper";
Expand Down Expand Up @@ -76,15 +76,14 @@ export default function runTransform(transformConfig: ITransformConfig, action:
configurationName = "webpack." + config.configName + ".js";
}

pkgDir(process.cwd()).then((projectRoot) => {
const outputPath: string = initActionNotDefined
? transformConfig.configPath
: path.join(projectRoot || process.cwd(), configurationName);
const source: string = ast.toSource({
quote: "single",
});
runPrettier(outputPath, source);
const projectRoot = findProjectRoot(process.cwd());
const outputPath: string = initActionNotDefined
? transformConfig.configPath
: path.join(projectRoot || process.cwd(), configurationName);
const source: string = ast.toSource({
quote: "single",
});
runPrettier(outputPath, source);

})
.catch((err: IError) => {
Expand Down

0 comments on commit 9ad3c15

Please sign in to comment.