Skip to content

Commit afe3dbd

Browse files
committed
Do not prepack ignored packages
1 parent 59c66f5 commit afe3dbd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bob-the-bundler",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Bob The Bundler!",
55
"author": {
66
"email": "[email protected]",

src/commands/prepack.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import { writeFileSync, readFileSync } from "fs";
33

44
import { createCommand } from "../command";
55

6-
export const prepackCommand = createCommand(() => {
6+
export const prepackCommand = createCommand((api) => {
7+
const { config, reporter } = api;
78
return {
89
command: "prepack",
910
describe: "Prepares a package",
1011
handler() {
1112
const cwd = process.cwd();
1213
const srcPackageJson = readPackageJson(cwd);
14+
const fullName: string = srcPackageJson.name;
15+
16+
if ((config.ignore || []).includes(fullName)) {
17+
reporter.warn(`Ignored ${fullName}`);
18+
return;
19+
}
20+
1321
const distPackageJson = readPackageJson(join(cwd, "./dist"));
1422

1523
distPackageJson.version = srcPackageJson.version;
@@ -35,14 +43,14 @@ export const prepackCommand = createCommand(() => {
3543
join(cwd, "./dist/package.json"),
3644
JSON.stringify(distPackageJson, null, 2)
3745
);
38-
}
46+
},
3947
};
4048
});
4149

4250
function readPackageJson(path: string) {
4351
return JSON.parse(
4452
readFileSync(join(path, "./package.json"), {
45-
encoding: "utf-8"
53+
encoding: "utf-8",
4654
})
4755
);
4856
}

0 commit comments

Comments
 (0)