Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import globby from "globby";
import pLimit from "p-limit";
import fs from "fs-extra";
import { resolve, join } from "path";
import { Consola } from "consola";
import get from "lodash.get";

import { createCommand } from "../command";
import { Consola } from "consola";

// TODO: validate tsconfig.json (outDir, paths etc)
// TODO: validate package.json and main/module etc
import { BobConfig } from "../config";

interface BuildOptions {
external?: string[];
Expand Down Expand Up @@ -57,7 +55,7 @@ export const buildCommand = createCommand<

await Promise.all(
packages.map((packagePath) =>
limit(() => build(packagePath, config.scope, reporter))
limit(() => build(packagePath, config, reporter))
)
);
},
Expand Down Expand Up @@ -143,10 +141,22 @@ async function buildSingle() {
);
}

async function build(packagePath: string, scope: string, reporter: Consola) {
async function build(
packagePath: string,
config: BobConfig,
reporter: Consola
) {
const scope = config.scope;
const cwd = packagePath.replace("/package.json", "");
const pkg = await readPackageJson(cwd);
const name = pkg.name.replace(`${scope}/`, "");
const fullName: string = pkg.name;

if ((config.ignore || []).includes(fullName)) {
reporter.warn(`Ignored ${fullName}`);
return;
}

const name = fullName.replace(`${scope}/`, "");

validatePackageJson(pkg);

Expand Down Expand Up @@ -316,7 +326,7 @@ function rewritePackageJson(pkg: Record<string, any>) {
];

fields.forEach((field) => {
if (typeof pkg[field] !== 'undefined') {
if (typeof pkg[field] !== "undefined") {
newPkg[field] = pkg[field];
}
});
Expand Down