Skip to content

Commit

Permalink
Fix: windows-node path error
Browse files Browse the repository at this point in the history
  • Loading branch information
pandaoh authored and Lruihao committed Nov 27, 2023
1 parent 242d697 commit 7de414a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import https from 'https'
import { readFileSync } from 'fs';
import { readFileSync } from 'fs'
import { fileURLToPath } from 'url'
import { dirname, join } from 'path'

/**
* import json file
* @param {String} relativePath relative path to json file
* @returns
* @returns
*/
function importJson(relativePath) {
return JSON.parse(readFileSync(new URL(relativePath, import.meta.url).pathname, 'utf8'))
const moduleURL = new URL(import.meta.url)
const modulePath = fileURLToPath(moduleURL)
const basePath = dirname(modulePath)
const filePath = join(basePath, relativePath)
const fileContent = readFileSync(filePath, 'utf8')
return JSON.parse(fileContent)
}

/**
* get latest release info from GitHub API
* @param {String} repoOwner repo owner
Expand Down

0 comments on commit 7de414a

Please sign in to comment.