Skip to content

Commit

Permalink
feat: use npm root -g for npmDir
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud committed Oct 7, 2024
1 parent 57aa54c commit b4e7bae
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/handlers/initHandlers/setNpmDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const initSetNpmDir = (_event: IpcMainEvent | IpcMainInvokeEvent) => {
return new Promise<ConfigData>((resolve) => {
try {
// npm config get prefix
const cmd = `npm config get prefix`
// const cmd = `npm config get prefix`
const cmd = `npm root -g`
exec(cmd, (error, stdout, stderr) => {
if (error) {
mainLog.error(`exec error: ${error}`)
Expand All @@ -33,10 +34,11 @@ export const initSetNpmDir = (_event: IpcMainEvent | IpcMainInvokeEvent) => {
}
if (stderr) mainLog.debug(`stderr: ${stderr}`)
if (stdout) {
const returned: string =
os.platform() === 'win32'
? path.join(stdout.trim(), `node_modules`)
: path.join(stdout.trim(), `lib`, `node_modules`)
// const returned: string =
// os.platform() === 'win32'
// ? path.join(stdout.trim(), `node_modules`)
// : path.join(stdout.trim(), `lib`, `node_modules`)
const returned: string = stdout.trim()
setNpmDir(returned)
store.set(`npmDir`, returned)
toReturned.result = returned
Expand Down

0 comments on commit b4e7bae

Please sign in to comment.