channel-worker 1.0.16 → 1.0.17
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/lib/command-poller.js +32 -1
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -85,7 +85,38 @@ class CommandPoller {
|
|
|
85
85
|
} catch { /* ignore */ }
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const baseExtPath = this.config.extension_path || '';
|
|
89
|
+
let extensionPath = baseExtPath;
|
|
90
|
+
|
|
91
|
+
// Create per-profile extension dir with config.json containing profileId
|
|
92
|
+
if (baseExtPath && profile_id) {
|
|
93
|
+
const fs = require('fs');
|
|
94
|
+
const path = require('path');
|
|
95
|
+
const profileExtPath = baseExtPath + '-' + profile_id;
|
|
96
|
+
try {
|
|
97
|
+
// Copy extension files to per-profile dir (if not exists or outdated)
|
|
98
|
+
if (!fs.existsSync(profileExtPath)) fs.mkdirSync(profileExtPath, { recursive: true });
|
|
99
|
+
const files = fs.readdirSync(baseExtPath);
|
|
100
|
+
for (const f of files) {
|
|
101
|
+
const src = path.join(baseExtPath, f);
|
|
102
|
+
const dst = path.join(profileExtPath, f);
|
|
103
|
+
if (fs.statSync(src).isFile()) {
|
|
104
|
+
// Copy if newer
|
|
105
|
+
const srcMtime = fs.statSync(src).mtimeMs;
|
|
106
|
+
const dstMtime = fs.existsSync(dst) ? fs.statSync(dst).mtimeMs : 0;
|
|
107
|
+
if (srcMtime > dstMtime) fs.copyFileSync(src, dst);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Write profile-specific config.json
|
|
111
|
+
const config = { channelManagerApi: 'https://api.channel.tunasm.art', profileId: profile_id };
|
|
112
|
+
fs.writeFileSync(path.join(profileExtPath, 'config.json'), JSON.stringify(config));
|
|
113
|
+
extensionPath = profileExtPath;
|
|
114
|
+
console.log(`[commands] Extension dir: ${profileExtPath} (profile: ${profile_id})`);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
console.warn(`[commands] Per-profile ext dir failed: ${e.message}, using base`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
89
120
|
const result = await this.nst.launchProfile(profile_id, { proxy, extensionPath });
|
|
90
121
|
console.log(`[commands] Profile ${profile_id} launched${extensionPath ? ' (ext)' : ''}`);
|
|
91
122
|
|