Skip to content

Commit 848d169

Browse files
authored
Added --package-json option to specify package json path (#322)
1 parent 250e9e1 commit 848d169

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/open-next/src/build.ts

100644100755
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ interface BuildOptions {
6868
* @default "."
6969
*/
7070
appPath?: string;
71+
72+
/**
73+
* The path to the package.json file. This path is relative from the current process.cwd().
74+
*/
75+
packageJsonPath?: string;
7176
}
7277

7378
const require = topLevelCreateRequire(import.meta.url);
@@ -117,7 +122,16 @@ function normalizeOptions(opts: BuildOptions, root: string) {
117122
const appPath = path.join(process.cwd(), opts.appPath || ".");
118123
const buildOutputPath = path.join(process.cwd(), opts.buildOutputPath || ".");
119124
const outputDir = path.join(buildOutputPath, ".open-next");
120-
const nextPackageJsonPath = findNextPackageJsonPath(appPath, root);
125+
126+
let nextPackageJsonPath: string;
127+
if (opts.packageJsonPath) {
128+
const _pkgPath = path.join(process.cwd(), opts.packageJsonPath);
129+
nextPackageJsonPath = _pkgPath.endsWith("package.json")
130+
? _pkgPath
131+
: path.join(_pkgPath, "./package.json");
132+
} else {
133+
nextPackageJsonPath = findNextPackageJsonPath(appPath, root);
134+
}
121135
return {
122136
openNextVersion: getOpenNextVersion(),
123137
nextVersion: getNextVersion(nextPackageJsonPath),

packages/open-next/src/index.ts

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ build({
1212
buildCommand: args["--build-command"],
1313
buildOutputPath: args["--build-output-path"],
1414
appPath: args["--app-path"],
15+
packageJsonPath: args["--package-json"],
1516
minify: Object.keys(args).includes("--minify"),
1617
streaming: Object.keys(args).includes("--streaming"),
1718
dangerous: {

0 commit comments

Comments
 (0)