Skip to content

Commit

Permalink
use null as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
idleberg committed Mar 22, 2024
1 parent 022e7ca commit e7fdb32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { spawn } from 'node:child_process';

import type { ChildProcess, SpawnOptions } from 'node:child_process';

function detectOutfile(str: string): string {
function detectOutfile(str: string): null | string {
if (str.includes('Output: "')) {
const regex = new RegExp('Output: "(.*.exe)"', 'g');
const result = regex.exec(str.toString());
Expand All @@ -13,12 +13,12 @@ function detectOutfile(str: string): string {
try {
return result['1'];
} catch (e) {
return '';
return null;
}
}
}

return '';
return null;
}

function formatOutput(stream: Makensis.StreamOptions, args: Array<string>, opts: Makensis.CompilerOptions): Makensis.StreamOptionsFormatted {
Expand Down Expand Up @@ -341,7 +341,7 @@ export function spawnMakensis(cmd: string, args: Array<string>, compilerOptions:
};

let warningsCounter = 0;
let outFile = '';
let outFile: string | null = '';

const child: ChildProcess = spawn(cmd, args, spawnOptions);

Expand Down Expand Up @@ -388,12 +388,12 @@ export function spawnMakensis(cmd: string, args: Array<string>, compilerOptions:

const output: Makensis.CompilerOutput = {
status: code,
stdout: streamFormatted.stdout || '',
stderr: streamFormatted.stderr || '',
stdout: streamFormatted.stdout || null,
stderr: streamFormatted.stderr || null,
warnings: warningsCounter,
};

if (outFile.length) {
if (outFile) {
output['outFile'] = outFile;
}

Expand Down
6 changes: 3 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare namespace Makensis {

interface CompilerData {
line: string;
outFile: string;
outFile: string | null;
hasWarning: boolean;
}

Expand Down Expand Up @@ -41,8 +41,8 @@ declare namespace Makensis {
interface CompilerOutput {
outFile?: string;
status: number;
stdout: string | HeaderInfo | HelpObject | Objectified;
stderr: string;
stdout: string | HeaderInfo | HelpObject | Objectified | null;
stderr: string | null;
warnings: number;
}

Expand Down

0 comments on commit e7fdb32

Please sign in to comment.