bm2 1.0.29 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +21 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bm2",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "A blazing-fast, full-featured process manager built entirely on Bun native APIs. The modern PM2 replacement — zero Node.js dependencies, pure Bun performance.",
5
5
  "main": "src/api.ts",
6
6
  "module": "src/api.ts",
package/src/index.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  import { existsSync, readFileSync, unlinkSync } from "fs";
19
- import { resolve, join, extname } from "path";
19
+ import path, { resolve, join, extname } from "path";
20
20
  import {
21
21
  APP_NAME,
22
22
  VERSION,
@@ -149,13 +149,25 @@ async function loadEcosystemConfig(filePath: string): Promise<EcosystemConfig> {
149
149
  }
150
150
 
151
151
  const ext = extname(abs);
152
+
153
+ let config;
154
+
152
155
  if (ext === ".json") {
153
- return await Bun.file(abs).json();
156
+ config = await Bun.file(abs).json() as EcosystemConfig;
154
157
  }
155
158
 
156
159
  // .ts, .js, .mjs — dynamic import
157
160
  const mod = await import(abs);
158
- return mod.default || mod;
161
+ config = (mod.default || mod) as EcosystemConfig;
162
+
163
+ const cwd = path.dirname(abs);
164
+
165
+ config.apps = config.apps.map(i => {
166
+ if ((i.cwd || "").trim() == "") i.cwd = cwd
167
+ return i;
168
+ })
169
+
170
+ return config
159
171
  }
160
172
 
161
173
  // ---------------------------------------------------------------------------
@@ -333,8 +345,8 @@ async function cmdStart(args: string[]) {
333
345
  scriptOrConfig.includes("bm2.config") ||
334
346
  scriptOrConfig.includes("pm2.config")
335
347
  ) {
336
- const config = await loadEcosystemConfig(scriptOrConfig);
337
- const res = await sendToDaemon({ type: "ecosystem", data: config });
348
+ const {config, cwd } = await loadEcosystemConfig(scriptOrConfig);
349
+ const res = await sendToDaemon({ type: "ecosystem", data: { config, cwd } });
338
350
  if (!res.success) {
339
351
  console.error(colorize(`Error: ${res.error}`, "red"));
340
352
  process.exit(1);
@@ -346,8 +358,10 @@ async function cmdStart(args: string[]) {
346
358
  // Single script
347
359
  const opts = parseStartFlags(args.slice(1), resolve(scriptOrConfig));
348
360
  opts.script = resolve(scriptOrConfig);
361
+
362
+ const cwd = path.dirname(opts.script);
349
363
 
350
- const res = await sendToDaemon({ type: "start", data: opts });
364
+ const res = await sendToDaemon({ type: "start", data: { config: opts, cwd } });
351
365
  if (!res.success) {
352
366
  console.error(colorize(`Error: ${res.error}`, "red"));
353
367
  process.exit(1);
@@ -681,7 +695,7 @@ async function cmdDeploy(args: string[]) {
681
695
  process.exit(1);
682
696
  }
683
697
 
684
- const config = await loadEcosystemConfig(configFile);
698
+ const {config, cwd } = await loadEcosystemConfig(configFile);
685
699
  if (!config.deploy || !config.deploy[environment]) {
686
700
  console.error(colorize(`Deploy environment "${environment}" not found in config`, "red"));
687
701
  process.exit(1);