@hile/schedule 2.0.0 → 2.0.1

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/dist/scheduler.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { scheduleJob } from 'node-schedule';
2
- import { glob } from 'glob';
3
- import { resolve } from 'node:path';
4
2
  import { pathToFileURL } from 'node:url';
3
+ import { scanDirectory } from '@hile/loader';
5
4
  export class Scheduler {
6
5
  jobs = new Map();
7
6
  meta = new Map();
@@ -62,12 +61,10 @@ export class Scheduler {
62
61
  * @returns 注销函数
63
62
  */
64
63
  async load(directory, options) {
65
- const suffix = options?.suffix || 'schedule';
66
- const files = await glob(`**/*.${suffix}.{ts,js,tsx,jsx,mjs}`, { cwd: directory });
64
+ const files = await scanDirectory(directory, { suffix: options?.suffix || 'schedule' });
67
65
  const offFns = [];
68
66
  for (const file of files) {
69
- const filePath = resolve(directory, file);
70
- const mod = await import(pathToFileURL(filePath).href);
67
+ const mod = await import(pathToFileURL(file.absolute).href);
71
68
  const jobDef = mod.default;
72
69
  if (!jobDef || jobDef.type !== 'job')
73
70
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hile/schedule",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Declarative job scheduler based on node-schedule",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,8 +23,8 @@
23
23
  "vitest": "^4.0.18"
24
24
  },
25
25
  "dependencies": {
26
- "glob": "^13.0.6",
26
+ "@hile/loader": "^2.0.1",
27
27
  "node-schedule": "^2.1.1"
28
28
  },
29
- "gitHead": "8e0fd1f78b5a8abd21218d1f596ada2533a0c8e7"
29
+ "gitHead": "2c8011db01f2815e5ce34de964d5492640396828"
30
30
  }