Skip to content

Commit

Permalink
Check if yarn installed before asking (#249)
Browse files Browse the repository at this point in the history
* check if yarn installed

* ask for package manager if yarn installed

* bump version to 1.1.5
  • Loading branch information
aliemir authored May 17, 2021
1 parent 36169ae commit 38fd9a7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superplate-cli",
"version": "1.1.4",
"version": "1.1.5",
"description": "The frontend boilerplate with superpowers",
"license": "MIT",
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions src/Helper/binary/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BinaryHelper } from "./";

describe("Binary Helper", () => {
it("has CanUseYarn function", async () => {
expect(typeof BinaryHelper.CanUseYarn).toBe("function");
});
});
12 changes: 12 additions & 0 deletions src/Helper/binary/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { execSync } from "child_process";

export const BinaryHelper = {
CanUseYarn: (): boolean => {
try {
execSync("yarn --version", { stdio: "ignore" });
return true;
} catch (e) {
return false;
}
},
};
1 change: 1 addition & 0 deletions src/Helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export { UrlHelper } from "./url";
export { GitHelper } from "./git";
export { FSHelper } from "./fs";
export { tips } from "./tips";
export { BinaryHelper } from "./binary";
25 changes: 15 additions & 10 deletions src/saofile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mergeBabel,
tips,
mergePluginData,
BinaryHelper,
} from "@Helper";

const saoConfig: GeneratorConfig = {
Expand All @@ -37,16 +38,20 @@ const saoConfig: GeneratorConfig = {
message: "What will be the name of your app",
default: appName,
},
{
name: "pm",
message: "Package manager:",
choices: [
{ message: "Npm", value: "npm" },
{ message: "Yarn", value: "yarn" },
],
type: "select",
default: "npm",
},
...(BinaryHelper.CanUseYarn()
? [
{
name: "pm",
message: "Package manager:",
choices: [
{ message: "Npm", value: "npm" },
{ message: "Yarn", value: "yarn" },
],
type: "select",
default: "npm",
},
]
: []),
...(sourcePrompts?.prompts ?? []),
];
},
Expand Down

0 comments on commit 38fd9a7

Please sign in to comment.