Skip to content

Commit 963c85f

Browse files
Merge pull request #818 from pranshuchittora/refactor-utils
misc: Refactoring utils
2 parents 8506ccf + 80fd4fa commit 963c85f

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

packages/utils/defineTest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from "fs";
22
import * as path from "path";
3+
34
import { IJSCodeshift, INode } from "./types/NodePath";
45

56
interface IModule {

packages/utils/find-root.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import * as findup from "findup-sync";
22
import * as path from "path";
33

4+
/**
5+
* Returns the absolute path of the project directory
6+
* Finds the package.json, by using findup-sync
7+
* @returns {String} path of project directory
8+
*/
9+
410
export function findProjectRoot(): string {
511
const rootFilePath = findup(`package.json`);
612
const projectRoot = path.dirname(rootFilePath);

packages/utils/scaffold.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,16 @@ export default function runTransform(transformConfig: ITransformConfig, action:
9090
console.error(err.message ? err.message : err);
9191
});
9292
});
93-
93+
let successMessage: string = `Congratulations! Your new webpack configuration file has been created!\n`;
9494
if (initActionNotDefined && transformConfig.config.item) {
95-
process.stdout.write(
96-
"\n" +
97-
chalk.green(
98-
`Congratulations! ${
99-
transformConfig.config.item
100-
} has been ${action}ed!\n`,
101-
),
102-
);
103-
} else {
104-
process.stdout.write(
105-
"\n" +
106-
chalk.green(
107-
"Congratulations! Your new webpack configuration file has been created!\n",
108-
),
109-
);
95+
successMessage = `Congratulations! ${
96+
transformConfig.config.item
97+
} has been ${action}ed!\n`;
11098
}
99+
process.stdout.write(
100+
"\n" +
101+
chalk.green(
102+
successMessage,
103+
),
104+
);
111105
}

0 commit comments

Comments
 (0)