mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix dirname for Node 18
This commit is contained in:
@ -3,12 +3,14 @@
|
|||||||
// 1. node plugins.js update
|
// 1. node plugins.js update
|
||||||
// 2. node plugins.js install <plugin-git-url>
|
// 2. node plugins.js install <plugin-git-url>
|
||||||
// More operations coming soon.
|
// More operations coming soon.
|
||||||
import { default as git } from 'simple-git';
|
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
import { default as git } from 'simple-git';
|
||||||
import { color } from './src/util.js';
|
import { color } from './src/util.js';
|
||||||
|
|
||||||
const __dirname = import.meta.dirname;
|
const __dirname = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url));
|
||||||
process.chdir(__dirname);
|
process.chdir(__dirname);
|
||||||
const pluginsPath = './plugins';
|
const pluginsPath = './plugins';
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import * as path from 'node:path';
|
|||||||
import * as util from 'node:util';
|
import * as util from 'node:util';
|
||||||
import * as net from 'node:net';
|
import * as net from 'node:net';
|
||||||
import * as dns from 'node:dns';
|
import * as dns from 'node:dns';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
// cli/fs related library imports
|
// cli/fs related library imports
|
||||||
import open from 'open';
|
import open from 'open';
|
||||||
@ -214,7 +215,7 @@ const cliArguments = yargs(hideBin(process.argv))
|
|||||||
}).parseSync();
|
}).parseSync();
|
||||||
|
|
||||||
// change all relative paths
|
// change all relative paths
|
||||||
const serverDirectory = import.meta.dirname;
|
const serverDirectory = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url));
|
||||||
console.log(`Node version: ${process.version}. Running in ${process.env.NODE_ENV} environment. Server directory: ${serverDirectory}`);
|
console.log(`Node version: ${process.version}. Running in ${process.env.NODE_ENV} environment. Server directory: ${serverDirectory}`);
|
||||||
process.chdir(serverDirectory);
|
process.chdir(serverDirectory);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user