Skip to content

Commit

Permalink
fixes, type improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
idleberg committed Jul 8, 2023
1 parent 3d5b449 commit 4f48d02
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@
"default": false,
"description": "Toggle ANSI deprecation warning",
"order": 19
},
"nsis.disableTelemetry": {
"type": "boolean",
"default": false,
"description": "Disables extension telemetry, even though the global preferences might allow tracking",
"order": 20
}
}
},
Expand Down
21 changes: 11 additions & 10 deletions src/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
import { fileExists, getMakensisPath, isWindowsCompatible, buttonHandler } from './util';
import { getConfig } from 'vscode-get-config';
import { platform } from 'os';
import { type CompilerOutput } from 'makensis';
import nsisChannel from './channel';
import vscode from 'vscode';

export async function compilerOutputHandler(data: unknown): Promise<void> {
export async function compilerOutputHandler(data: CompilerOutput): Promise<void> {
const { showOutputView } = await getConfig('nsis');

nsisChannel.appendLine(data['line']);
nsisChannel.appendLine(data.line);

if (showOutputView === 'Always') {
nsisChannel.show();
}
}

export async function compilerErrorHandler(data: unknown): Promise<void> {
export async function compilerErrorHandler(data: CompilerOutput): Promise<void> {
const { showOutputView } = await getConfig('nsis');

nsisChannel.appendLine(data['line']);
nsisChannel.appendLine(data.line);

if (showOutputView === 'On Errors') {
nsisChannel.show();
}
}

export async function compilerExitHandler(data: unknown): Promise<void> {
export async function compilerExitHandler(data: CompilerOutput): Promise<void> {
const { showNotifications, showOutputView } = await getConfig('nsis');

if (data['status'] === 0) {
if (showOutputView === 'Always') {
nsisChannel.show();
}

const outfileExists = await fileExists(data['outFile']);
const outfileExists = await fileExists(String(data.outFile));

const openButton = (await isWindowsCompatible() === true && data['outFile']?.length && outfileExists)
const openButton = (await isWindowsCompatible() === true && data.outFile?.length && outfileExists)
? 'Run'
: undefined;

Expand All @@ -48,10 +49,10 @@ export async function compilerExitHandler(data: unknown): Promise<void> {
}

const choice = await vscode.window.showWarningMessage(`Compiled with warnings`, openButton, revealButton);
await buttonHandler(choice, data['outFile']);
await buttonHandler(choice, data.outFile);
} else if (showNotifications) {
const choice = await vscode.window.showInformationMessage(`Compiled successfully`, openButton, revealButton);
await buttonHandler(choice, data['outFile']);
await buttonHandler(choice, data.outFile);
}
} else if (showNotifications) {
if (showOutputView !== 'Never') {
Expand Down Expand Up @@ -86,7 +87,7 @@ export async function versionHandler(data: unknown): Promise<void> {
const { showVersionAsInfoMessage } = await getConfig('nsis');
const pathToMakensis = await getMakensisPath();

const output = data['stdout'] || data['stderr'];
const output = data.stdout || data.stderr;
const message = `makensis ${output} (${pathToMakensis})`;

if (showVersionAsInfoMessage === true) {
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { compile, showCompilerFlags, showVersion, showHelp } from './makensis';
import { convert } from './nlf';
import { createTask } from './task';
import { getConfig } from 'vscode-get-config';
import { reporter } from './telemetry';
import { reporter, sendTelemetryEvent } from './telemetry';
import { updateDiagnostics } from './diagnostics';

async function activate(context: ExtensionContext): Promise<void> {
const { disableTelemetry } = await getConfig('applescript');
const { disableTelemetry } = await getConfig('nsis');

if (disableTelemetry === false) {
context.subscriptions.push(reporter);
Expand Down Expand Up @@ -60,8 +60,9 @@ async function activate(context: ExtensionContext): Promise<void> {
);

context.subscriptions.push(
commands.registerCommand('extension.nsis.open-settings', () => {
commands.registerCommand('extension.nsis.open-settings', async () => {
commands.executeCommand('workbench.action.openSettings', '@ext:idleberg.nsis');
await sendTelemetryEvent('openSettings');
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export async function sendTelemetryEvent(name: string, properties: Record<string
reporter.sendTelemetryEvent(name, stringifyProperties(properties), measurements);
}

export const reporter = new TelemetryReporter('c274f50c-8f94-470c-98f1-006585e3aecc');
export const reporter = new TelemetryReporter('71c4e4b9-6847-41f0-8ea3-a35821fa41e0');

0 comments on commit 4f48d02

Please sign in to comment.