Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add configuration for external host #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"type": "boolean",
"default": true,
"description": "Show notification"
},
"masscode-assistant.host": {
"type":"string",
"default": "localhost",
"description": "Specifies the host of an active massCode app"
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import axios from 'axios'
import type { Snippet } from './types'

export function activate (context: vscode.ExtensionContext) {
const preferences = vscode.workspace.getConfiguration('masscode-assistant')
const host = preferences.get('host')
const search = vscode.commands.registerCommand(
'masscode-assistant.search',
async () => {
try {
const { data } = await axios.get<Snippet[]>(
'http://localhost:3033/snippets/embed-folder'
`http://${host}:3033/snippets/embed-folder`
)

const lastSelectedId = context.globalState.get('masscode:last-selected')
Expand Down Expand Up @@ -86,6 +88,7 @@ export function activate (context: vscode.ExtensionContext) {
vscode.commands.executeCommand('editor.action.clipboardCopyAction')

const preferences = vscode.workspace.getConfiguration('masscode-assistant')
const host = preferences.get('host')
const isNotify = preferences.get('notify')

const content = await vscode.env.clipboard.readText()
Expand All @@ -106,7 +109,7 @@ export function activate (context: vscode.ExtensionContext) {
]

try {
await axios.post('http://localhost:3033/snippets/create', body)
await axios.post(`http://${host}:3033/snippets/create`, body)

if (isNotify) {
vscode.window.showInformationMessage('Snippet successfully created')
Expand Down