Skip to content

Commit 618ba98

Browse files
committed
fix path loaded and convert to mjs
1 parent 05e1a66 commit 618ba98

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/Commands/TransSFCServe.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TransSFCServe extends Command
1313

1414
public function handle(): int
1515
{
16-
$nodeScriptPath = base_path('vendor/iammarjamal/transsfc/src/Watcher/index.js');
16+
$nodeScriptPath = base_path('vendor/iammarjamal/transsfc/src/Watcher/index.mjs');
1717

1818
if (!file_exists($nodeScriptPath)) {
1919
$this->error("Node.js script not found at: {$nodeScriptPath}");
@@ -43,4 +43,4 @@ public function handle(): int
4343
$this->info('✅ Script ran successfully');
4444
return self::SUCCESS;
4545
}
46-
}
46+
}

src/Watcher/index.js renamed to src/Watcher/index.mjs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Import required modules.
2-
const chokidar = require("chokidar"); // Module for watching file changes.
3-
const fs = require("fs-extra"); // Module for file system operations.
4-
const path = require("path"); // Module for handling file paths.
5-
const crypto = require("crypto"); // Module for generating file hashes.
2+
import chokidar from "chokidar"; // Module for watching file changes.
3+
import fs from "fs-extra"; // Module for file system operations.
4+
import path from "path"; // Module for handling file paths.
5+
import crypto from "crypto"; // Module for generating file hashes.
6+
7+
// Get the absolute path of the Laravel project
8+
const laravelProjectPath = process.cwd(); // Correct Laravel project root
69

710
// Define paths for Blade views and translation files.
8-
const viewsPath = path.join(__dirname, "../../../resources/views");
9-
const langPath = path.join(__dirname, "../../../lang");
11+
const viewsPath = path.join(laravelProjectPath, "resources/views");
12+
const langPath = path.join(laravelProjectPath, "lang");
1013

1114
console.log(
1215
"🔍 Starting async watch on Blade files for translation updates..."
@@ -407,4 +410,4 @@ chokidar
407410
removeTranslationsForFile(filePath);
408411
});
409412

410-
console.log("Async Lang watcher is running...");
413+
console.log("Async Lang watcher is running...");

0 commit comments

Comments
 (0)