Skip to content

Commit 71c1092

Browse files
authored
fix(pack): ignore .oo-thumbnail.json (#63)
Signed-off-by: Kevin Cui <[email protected]>
1 parent 81c66ad commit 71c1092

File tree

9 files changed

+60
-0
lines changed

9 files changed

+60
-0
lines changed

src/cmd/pack.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,35 @@ describe("pack", () => {
8282
}
8383
await remove(tgz);
8484
});
85+
86+
it("should not ignore .oo-thumbnail.json", async (ctx) => {
87+
const _p = fixture("pack_ignore");
88+
const p = path.join(path.dirname(_p), "__TEMP_pack_ignore");
89+
90+
ctx.onTestFinished(async () => {
91+
await remove(p);
92+
});
93+
94+
await copyDir(_p, p);
95+
await move(path.join(p, "_gitignore"), path.join(p, ".gitignore"));
96+
97+
const tgz = path.join(p, "pack_ignore-0.0.1.tgz");
98+
await remove(tgz);
99+
await pack(p, p);
100+
101+
await expect(exists(tgz)).resolves.toBe(true);
102+
103+
{
104+
const result: string[] = [];
105+
await tar.t({
106+
f: tgz,
107+
onReadEntry: (entry) => {
108+
result.push(entry.path.replaceAll("\\", "/"));
109+
},
110+
});
111+
112+
expect(result).toContainEqual("package/package/.oo-thumbnail.json");
113+
}
114+
await remove(tgz);
115+
});
85116
});

src/utils/npm.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe.concurrent("generatePackageJson", () => {
5555
files: [
5656
"package",
5757
"package/.gitignore",
58+
"package/.oo-thumbnail.json",
5859
],
5960
});
6061
});
@@ -76,6 +77,7 @@ describe.concurrent("generatePackageJson", () => {
7677
files: [
7778
"package",
7879
"package/.gitignore",
80+
"package/.oo-thumbnail.json",
7981
],
8082
});
8183
});

src/utils/npm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export async function generatePackageJson(dir: string, stringify = true): Promis
4848
content.files = [
4949
"package",
5050
"package/.gitignore",
51+
"package/.oo-thumbnail.json",
5152
];
5253

5354
if (stringify) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"//": "PASS"
3+
}

tests/fixtures/pack_ignore/_gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
aaa
2+
3+
.oo-thumbnail.json
4+
5+
foo.txt

tests/fixtures/pack_ignore/foo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PASS
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "pack_ignore",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC"
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: pack_ignore
2+
version: 0.0.1
3+
dependencies:
4+
a: 1.0.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// PASS

0 commit comments

Comments
 (0)