Skip to content

Commit 98d3c21

Browse files
authored
feat(pack): support icon (#26)
Signed-off-by: Kevin Cui <[email protected]>
1 parent c8d68cf commit 98d3c21

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ export interface OOPackageSchema {
3535
author?: string;
3636
dependencies?: Record<string, string>;
3737
scripts: Record<string, string>;
38+
icon?: string;
3839
}

src/utils/npm.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe.concurrent("generatePackageJson", () => {
3737
author: "Kevin Cui <[email protected]>",
3838
description: "A test package",
3939
keywords: ["test", "package"],
40+
icon: "icon.png",
4041
dependencies: {
4142
foo: "1.0.0",
4243
bar: "1.0.0",
@@ -50,6 +51,7 @@ describe.concurrent("generatePackageJson", () => {
5051
expect(result).toEqual({
5152
...content,
5253
scripts: {},
54+
icon: path.join("package", "icon.png"),
5355
});
5456
});
5557
});

src/utils/npm.ts

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export async function generatePackageJson(dir: string, stringify = true): Promis
3636
throw new Error(`Miss required field: version in ${ooPackagePath}`);
3737
}
3838

39+
if (content.icon) {
40+
content.icon = path.join("package", content.icon);
41+
}
42+
3943
content.scripts = {};
4044

4145
if (stringify) {

0 commit comments

Comments
 (0)