fork-ts-checker-webpack-plugin
Advanced tools
Comparing version 7.2.4 to 7.2.5
@@ -73,3 +73,3 @@ "use strict"; | ||
*/ | ||
ForkTsCheckerWebpackPlugin.version = '7.2.4'; // will be replaced by the @semantic-release/exec | ||
ForkTsCheckerWebpackPlugin.version = '7.2.5'; // will be replaced by the @semantic-release/exec | ||
/** | ||
@@ -76,0 +76,0 @@ * Default pools for the plugin concurrency limit |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -32,3 +13,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
exports.wrapRpc = void 0; | ||
const process = __importStar(require("process")); | ||
const controlled_promise_1 = require("../utils/async/controlled-promise"); | ||
const rpc_error_1 = require("./rpc-error"); | ||
@@ -45,46 +26,48 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const id = uuid(); | ||
const resultPromise = new Promise((resolve, reject) => { | ||
const handleMessage = (message) => { | ||
if (message.id === id) { | ||
if (message.type === 'resolve') { | ||
resolve(message.value); | ||
unsubscribe(); | ||
} | ||
else if (message.type === 'reject') { | ||
reject(message.error); | ||
unsubscribe(); | ||
} | ||
// create promises | ||
const { promise: resultPromise, resolve: resolveResult, reject: rejectResult, } = (0, controlled_promise_1.createControlledPromise)(); | ||
const { promise: sendPromise, resolve: resolveSend, reject: rejectSend, } = (0, controlled_promise_1.createControlledPromise)(); | ||
const handleMessage = (message) => { | ||
if ((message === null || message === void 0 ? void 0 : message.id) === id) { | ||
if (message.type === 'resolve') { | ||
// assume the contract is respected | ||
resolveResult(message.value); | ||
removeHandlers(); | ||
} | ||
}; | ||
const handleClose = (code, signal) => { | ||
reject(new rpc_error_1.RpcExitError(code | ||
? `Process ${process.pid} exited with code "${code}" [${signal}]` | ||
: `Process ${process.pid} exited [${signal}].`, code, signal)); | ||
unsubscribe(); | ||
}; | ||
const subscribe = () => { | ||
childProcess.on('message', handleMessage); | ||
childProcess.on('close', handleClose); | ||
}; | ||
const unsubscribe = () => { | ||
childProcess.off('message', handleMessage); | ||
childProcess.off('exit', handleClose); | ||
}; | ||
subscribe(); | ||
}); | ||
yield new Promise((resolve, reject) => { | ||
childProcess.send({ | ||
type: 'call', | ||
id, | ||
args, | ||
}, (error) => { | ||
if (error) { | ||
reject(error); | ||
else if (message.type === 'reject') { | ||
rejectResult(message.error); | ||
removeHandlers(); | ||
} | ||
else { | ||
resolve(undefined); | ||
} | ||
}); | ||
} | ||
}; | ||
const handleClose = (code, signal) => { | ||
rejectResult(new rpc_error_1.RpcExitError(code | ||
? `Process ${childProcess.pid} exited with code ${code}` + | ||
(signal ? ` [${signal}]` : '') | ||
: `Process ${childProcess.pid} exited` + (signal ? ` [${signal}]` : ''), code, signal)); | ||
removeHandlers(); | ||
}; | ||
// to prevent event handler leaks | ||
const removeHandlers = () => { | ||
childProcess.off('message', handleMessage); | ||
childProcess.off('close', handleClose); | ||
}; | ||
// add event listeners | ||
childProcess.on('message', handleMessage); | ||
childProcess.on('close', handleClose); | ||
// send call message | ||
childProcess.send({ | ||
type: 'call', | ||
id, | ||
args, | ||
}, (error) => { | ||
if (error) { | ||
rejectSend(error); | ||
removeHandlers(); | ||
} | ||
else { | ||
resolveSend(undefined); | ||
} | ||
}); | ||
return resultPromise; | ||
return sendPromise.then(() => resultPromise); | ||
})); | ||
@@ -91,0 +74,0 @@ } |
{ | ||
"name": "fork-ts-checker-webpack-plugin", | ||
"version": "7.2.4", | ||
"version": "7.2.5", | ||
"description": "Runs typescript type checker and linter on separate process.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
228135
182
4315