befly 3.71.0 → 3.72.0

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.
package/index.js CHANGED
@@ -177,7 +177,7 @@ export class Befly {
177
177
  await ensureSyncPrerequisites(this.context);
178
178
 
179
179
  // 自动同步(PM2 cluster:主进程执行,其它进程等待同步完成)
180
- if (isPrimaryProcess(Bun.env)) {
180
+ if (isPrimaryProcess()) {
181
181
  await syncApi(this.context, this.apis);
182
182
  await syncMenu(this.context, this.menus);
183
183
  await syncDev(this.context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.71.0",
3
+ "version": "3.72.0",
4
4
  "gitHead": "49c39d36695036e85fc64083cc43c1652fff96cb",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
package/plugins/cron.js CHANGED
@@ -16,7 +16,7 @@ const jobs = new Map();
16
16
  * @returns {CronJob|null}
17
17
  */
18
18
  function register(context, name, schedule, task) {
19
- if (!isPrimaryProcess(context.env)) {
19
+ if (!isPrimaryProcess()) {
20
20
  return null;
21
21
  }
22
22
 
@@ -42,7 +42,7 @@ function register(context, name, schedule, task) {
42
42
  * 注册一个按秒执行的定时任务
43
43
  */
44
44
  function second(context, name, seconds, task) {
45
- if (!isPrimaryProcess(context.env)) {
45
+ if (!isPrimaryProcess()) {
46
46
  return null;
47
47
  }
48
48
 
package/utils/is.js CHANGED
@@ -349,8 +349,9 @@ export function isEmpty(value) {
349
349
  * 判断当前进程是否为主进程。
350
350
  * PM2 cluster 的实例 0 是主进程;未由 PM2 启动时视为主进程。
351
351
  */
352
- export function isPrimaryProcess(env) {
353
- return env.NODE_APP_INSTANCE === "0" || env.NODE_APP_INSTANCE === 0 || env.NODE_APP_INSTANCE === undefined;
352
+ export function isPrimaryProcess() {
353
+ const instance = Bun.env.NODE_APP_INSTANCE;
354
+ return instance === "0" || instance === 0 || instance === undefined;
354
355
  }
355
356
 
356
357
  export const isDirentDirectory = (parentDir, entry) => {