Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 25fe9da

Browse files
committed
WIP Make GitPromptServer work on Windows (fix test)
1 parent 6a2b39c commit 25fe9da

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/git-prompt-server.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @babel */
22
import net from 'net'
33
import path from 'path'
4+
import os from 'os'
45

56
import Prompt from './views/prompt'
67
import {deleteFolder, getTempDir} from './helpers'
@@ -37,12 +38,13 @@ function getInputViaPrompt (query) {
3738
export default class GitPromptServer {
3839
async start (promptForInput = getInputViaPrompt) {
3940
// TODO: [mkt] Windows?? yes.
40-
const windows = process.platform === 'win32'
4141
this.promptForInput = promptForInput
42-
this.tmpFolderPath = await getTempDir(windows ? 'C:\Windows\Temp' : '/tmp/github-git-prompt-server-')
42+
const windows = process.platform === 'win32'
43+
const prefix = windows ? os.tmpdir() : '/tmp'
44+
this.tmpFolderPath = await getTempDir(path.join(prefix, 'github'))
4345
const socketPath = path.join(this.tmpFolderPath, 'helper.sock')
4446
const namedPipePath = path.join('\\\\?\\pipe\\', 'gh-' + require("crypto").randomBytes(8).toString('hex'), 'helper.sock')
45-
this.server = await this.startListening(socketPath)
47+
this.server = await this.startListening(windows ? namedPipePath : socketPath)
4648

4749
return {
4850
socket: windows ? namedPipePath : socketPath,

0 commit comments

Comments
 (0)