Skip to content

Commit 5c4e5ee

Browse files
Allow custom package manager names in packageManager field and update related logic.
1 parent 9e5a86a commit 5c4e5ee

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,22 @@ image:
8282
fontSize: 100px
8383
icon: code
8484
85-
packageManager: auto # composer | npm | yarn | auto | none
85+
# Declares the use of the package manager.
86+
# It is a regular string that will be substituted into the URL address.
87+
#
88+
# Reserved words: composer | npm | yarn | auto | none
89+
#
90+
# Any package manager name can be specified.
91+
#
92+
# By default, auto
93+
packageManager: auto
8694
8795
# By default, the package name is taken from the composer.json or package.json file.
8896
packageName: ''
8997
9098
# Add a prefix for global installation (`composer global require`, `npm install -g`)
99+
# The parameter will be ignored when a non-standard package manager name is specified in
100+
# the `packageManager` parameter.
91101
packageGlobal: false
92102

93103
# By default, the repository name will be used.

src/types/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface ImageParameters {
44
fontSize: string;
55
icon: string;
66

7-
packageManager: "composer" | "npm" | "yarn" | "auto" | "none";
7+
packageManager: "composer" | "npm" | "yarn" | "auto" | "none" | string;
88
packageName?: string;
99
packageGlobal: boolean;
1010

src/utils/image.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ const packageManager = (config: Config): string => {
3030
return `yarn${visibility} add`;
3131
case "auto":
3232
return detectPackageManager(config, visibility);
33-
default:
33+
case "none":
3434
return "";
35+
default:
36+
return config.image.parameters.packageManager;
3537
}
3638
};
3739

src/utils/packageManagers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import type { Package } from "../types/package";
44

55
export const hasComposer = (config: Config): boolean =>
66
fileExists(config, "composer.json");
7+
78
export const hasNpm = (config: Config): boolean =>
89
fileExists(config, "package.json");
10+
911
export const hasYarn = (config: Config): boolean =>
1012
fileExists(config, "yarn.lock");
1113

1214
export const getComposer = (config: Config): Package =>
1315
<Package>JSON.parse(readFile(config, "composer.json"));
16+
1417
export const getNpm = (config: Config): Package =>
1518
<Package>JSON.parse(readFile(config, "package.json"));
1619

0 commit comments

Comments
 (0)