Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scaffold): config file is always generated at the project root #801

Merged
merged 6 commits into from Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/utils/package.json
Expand Up @@ -18,6 +18,7 @@
"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
16 changes: 10 additions & 6 deletions packages/utils/scaffold.ts
Expand Up @@ -2,7 +2,9 @@ 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 { IError } from "../init/types";
import { IConfig, ITransformConfig } from "./modify-config-helper";
import propTypes from "./prop-types";
import astTransform from "./recursive-parser";
Expand Down Expand Up @@ -74,14 +76,16 @@ export default function runTransform(transformConfig: ITransformConfig, action:
configurationName = "webpack." + config.configName + ".js";
}

const outputPath: string = initActionNotDefined
? transformConfig.configPath
: path.join(process.cwd(), configurationName);
const source: string = ast.toSource({
quote: "single",
pkgDir(process.cwd()).then((projectRoot) => {
anshumanv marked this conversation as resolved.
Show resolved Hide resolved
const outputPath: string = initActionNotDefined
? transformConfig.configPath
: path.join(projectRoot || process.cwd(), configurationName);
const source: string = ast.toSource({
quote: "single",
});
runPrettier(outputPath, source);
});

runPrettier(outputPath, source);
})
.catch((err: IError) => {
console.error(err.message ? err.message : err);
Expand Down