@resourcexjs/cli 2.13.0 → 2.14.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/index.js CHANGED
@@ -4962,6 +4962,31 @@ class FolderSourceLoader {
4962
4962
  const files = await this.readFolderFiles(source);
4963
4963
  return { source, files };
4964
4964
  }
4965
+ async isFresh(source, cachedAt) {
4966
+ try {
4967
+ const maxMtime = await this.getMaxMtime(source);
4968
+ return maxMtime <= cachedAt;
4969
+ } catch {
4970
+ return false;
4971
+ }
4972
+ }
4973
+ async getMaxMtime(folderPath) {
4974
+ let max = new Date(0);
4975
+ const entries = await readdir2(folderPath, { withFileTypes: true });
4976
+ for (const entry of entries) {
4977
+ const fullPath = join2(folderPath, entry.name);
4978
+ if (entry.isFile()) {
4979
+ const stats = await stat2(fullPath);
4980
+ if (stats.mtime > max)
4981
+ max = stats.mtime;
4982
+ } else if (entry.isDirectory()) {
4983
+ const subMax = await this.getMaxMtime(fullPath);
4984
+ if (subMax > max)
4985
+ max = subMax;
4986
+ }
4987
+ }
4988
+ return max;
4989
+ }
4965
4990
  async readFolderFiles(folderPath, basePath = folderPath) {
4966
4991
  const files = {};
4967
4992
  const entries = await readdir2(folderPath, { withFileTypes: true });
@@ -17963,4 +17988,4 @@ var main = defineCommand({
17963
17988
  });
17964
17989
  runMain(main);
17965
17990
 
17966
- //# debugId=EFB446D3FE16011164756E2164756E21
17991
+ //# debugId=2856F8DBC43B5B9B64756E2164756E21