Fix dirname for Node 18
| @@ -3,12 +3,14 @@ | ||
| 3 | 3 | // 1. node plugins.js update |
| 4 | 4 | // 2. node plugins.js install <plugin-git-url> |
| 5 | 5 | // More operations coming soon. |
| 6 | -import { default as git } from 'simple-git'; | |
| 7 | 6 | import * as fs from 'node:fs'; |
| 8 | 7 | import * as path from 'node:path'; |
| 8 | +import { fileURLToPath } from 'node:url'; | |
| 9 | + | |
| 10 | +import { default as git } from 'simple-git'; | |
| 9 | 11 | import { color } from './src/util.js'; |
| 10 | 12 | |
| 11 | 13 | const __dirname = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url)); |
| 12 | 14 | process.chdir(__dirname); |
| 13 | 15 | const pluginsPath = './plugins'; |
| 14 | 16 | |
| @@ -8,6 +8,7 @@ import * as path from 'node:path'; | ||
| 8 | 8 | import * as util from 'node:util'; |
| 9 | 9 | import * as net from 'node:net'; |
| 10 | 10 | import * as dns from 'node:dns'; |
| 11 | +import { fileURLToPath } from 'node:url'; | |
| 11 | 12 | |
| 12 | 13 | // cli/fs related library imports |
| 13 | 14 | import open from 'open'; |
| @@ -214,7 +215,7 @@ const cliArguments = yargs(hideBin(process.argv)) | ||
| 214 | 215 | }).parseSync(); |
| 215 | 216 | |
| 216 | 217 | // change all relative paths |
| 217 | 218 | const serverDirectory = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url)); |
| 218 | 219 | console.log(`Node version: ${process.version}. Running in ${process.env.NODE_ENV} environment. Server directory: ${serverDirectory}`); |
| 219 | 220 | process.chdir(serverDirectory); |
| 220 | 221 | |