@iobroker/testing
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -9,2 +9,4 @@ /// <reference types="node" /> | ||
export declare function monkeyPatchGlobals(code: string, globals: Record<string, Record<string, any>>): string; | ||
/** Removes a hashbang from the code if it exists since that causes compilation errors */ | ||
export declare function removeHashbang(code: string): string; | ||
/** A test-safe replacement for process.exit that throws a specific error instead */ | ||
@@ -11,0 +13,0 @@ export declare function fakeProcessExit(code?: number): void; |
@@ -100,2 +100,7 @@ "use strict"; | ||
exports.monkeyPatchGlobals = monkeyPatchGlobals; | ||
/** Removes a hashbang from the code if it exists since that causes compilation errors */ | ||
function removeHashbang(code) { | ||
return code.replace(/^#!.+$/m, ""); | ||
} | ||
exports.removeHashbang = removeHashbang; | ||
/** A test-safe replacement for process.exit that throws a specific error instead */ | ||
@@ -146,2 +151,3 @@ function fakeProcessExit(code = 0) { | ||
module._compile = (code, _filename) => { | ||
code = removeHashbang(code); | ||
code = monkeyPatchGlobals(code, options.globalPatches); | ||
@@ -148,0 +154,0 @@ // Restore everything to not break the NodeJS internals |
{ | ||
"name": "@iobroker/testing", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Shared utilities for adapter and module testing in ioBroker", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
145567
3068