@polka-codes/runner 0.8.0 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.js +19 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25790,11 +25790,11 @@ var {
25790
25790
  Help
25791
25791
  } = import__.default;
25792
25792
  // package.json
25793
- var version = "0.8.0";
25793
+ var version = "0.8.1";
25794
25794
 
25795
25795
  // src/runner.ts
25796
25796
  import { execSync } from "node:child_process";
25797
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
25797
+ import { promises as fs5 } from "node:fs";
25798
25798
 
25799
25799
  // ../cli-shared/src/config.ts
25800
25800
  import { existsSync, readFileSync } from "node:fs";
@@ -54828,7 +54828,7 @@ class Runner {
54828
54828
  switch (change.status) {
54829
54829
  case "added":
54830
54830
  case "modified":
54831
- this.sendFileContent(change.path);
54831
+ await this.sendFileContent(change.path);
54832
54832
  break;
54833
54833
  case "deleted":
54834
54834
  this.sendFileDeleted(change.path);
@@ -54836,7 +54836,7 @@ class Runner {
54836
54836
  case "renamed":
54837
54837
  if (change.oldPath) {
54838
54838
  this.sendFileDeleted(change.oldPath);
54839
- this.sendFileContent(change.path);
54839
+ await this.sendFileContent(change.path);
54840
54840
  }
54841
54841
  break;
54842
54842
  }
@@ -54888,10 +54888,20 @@ class Runner {
54888
54888
  }
54889
54889
  return changes;
54890
54890
  }
54891
- sendFileContent(path4) {
54891
+ async sendFileContent(path4) {
54892
54892
  try {
54893
- if (existsSync2(path4)) {
54894
- const content = readFileSync2(path4, "utf8");
54893
+ const stat = await fs5.stat(path4).catch(() => null);
54894
+ if (!stat) {
54895
+ console.error(`File or directory not found: ${path4}`);
54896
+ return;
54897
+ }
54898
+ if (stat.isDirectory()) {
54899
+ const [files] = await listFiles(path4, true, 1000, process.cwd());
54900
+ for (const file of files) {
54901
+ await this.sendFileContent(file);
54902
+ }
54903
+ } else if (stat.isFile()) {
54904
+ const content = await fs5.readFile(path4, "utf8");
54895
54905
  this.wsManager.sendMessage({
54896
54906
  type: "file",
54897
54907
  path: path4,
@@ -54899,15 +54909,10 @@ class Runner {
54899
54909
  });
54900
54910
  console.log(`Sent content for file: ${path4}`);
54901
54911
  } else {
54902
- console.error(`File not found: ${path4}`);
54903
- this.wsManager.sendMessage({
54904
- type: "error",
54905
- message: "File not found",
54906
- details: path4
54907
- });
54912
+ console.error(`Path is not a file or directory: ${path4}`);
54908
54913
  }
54909
54914
  } catch (error) {
54910
- console.error(`Error reading file ${path4}:`, error);
54915
+ console.error(`Error processing path ${path4}:`, error);
54911
54916
  }
54912
54917
  }
54913
54918
  sendFileDeleted(path4) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",