mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-08-02 07:09:47 +08:00
feat(baoyu-post-to-wechat): support env var overrides for debug port and profile directory
This commit is contained in:
@@ -109,6 +109,8 @@ function sleep(ms: number): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getFreePort(): Promise<number> {
|
async function getFreePort(): Promise<number> {
|
||||||
|
const fixed = parseInt(process.env.WECHAT_BROWSER_DEBUG_PORT || '', 10);
|
||||||
|
if (fixed > 0) return fixed;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const server = net.createServer();
|
const server = net.createServer();
|
||||||
server.unref();
|
server.unref();
|
||||||
@@ -170,6 +172,8 @@ function findChromeExecutable(): string | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultProfileDir(): string {
|
function getDefaultProfileDir(): string {
|
||||||
|
const override = process.env.WECHAT_BROWSER_PROFILE_DIR?.trim();
|
||||||
|
if (override) return path.resolve(override);
|
||||||
const base = process.env.XDG_DATA_HOME || path.join(os.homedir(), '.local', 'share');
|
const base = process.env.XDG_DATA_HOME || path.join(os.homedir(), '.local', 'share');
|
||||||
return path.join(base, 'wechat-browser-profile');
|
return path.join(base, 'wechat-browser-profile');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user