From: Jérôme Benoit Date: Mon, 25 Sep 2023 18:39:34 +0000 (+0200) Subject: refactor: avoid direct process usage X-Git-Tag: v2.7.5~45 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4a6421b5261d2ebc33281682654361c5c4b2d069;p=poolifier.git refactor: avoid direct process usage Signed-off-by: Jérôme Benoit --- diff --git a/examples/typescript/http-server-pool/express-worker_threads/src/main.ts b/examples/typescript/http-server-pool/express-worker_threads/src/main.ts index 4f1a4d95..3bef1a8a 100644 --- a/examples/typescript/http-server-pool/express-worker_threads/src/main.ts +++ b/examples/typescript/http-server-pool/express-worker_threads/src/main.ts @@ -1,3 +1,4 @@ +import { exit } from 'node:process' import express, { type Express, type Request, type Response } from 'express' import { requestHandlerPool } from './pool.js' @@ -45,5 +46,5 @@ try { }) } catch (err) { console.error(err) - process.exit(1) + exit(1) } diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts index cc647a0f..724836de 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts @@ -1,5 +1,6 @@ import { dirname, extname, join } from 'node:path' import { fileURLToPath } from 'node:url' +import { exit } from 'node:process' import Fastify from 'fastify' import { fastifyPoolifier } from './fastify-poolifier.js' @@ -43,5 +44,5 @@ try { await fastify.listen({ port }) } catch (err) { fastify.log.error(err) - process.exit(1) + exit(1) } diff --git a/prepare.js b/prepare.js index eef41216..3dcaff37 100644 --- a/prepare.js +++ b/prepare.js @@ -1,4 +1,6 @@ -const isCIEnvironment = process.env.CI != null +const { env } = require('node:process') + +const isCIEnvironment = env.CI != null if (isCIEnvironment === false) { require('husky').install() } diff --git a/rollup.config.mjs b/rollup.config.mjs index aac1c8cd..8f1f2656 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,4 +1,5 @@ import * as os from 'node:os' +import { env } from 'node:process' import { dts } from 'rollup-plugin-dts' import terser from '@rollup/plugin-terser' import typescript from '@rollup/plugin-typescript' @@ -20,9 +21,9 @@ const availableParallelism = () => { return availableParallelism } -const isDevelopmentBuild = process.env.BUILD === 'development' -const isAnalyzeBuild = process.env.ANALYZE -const isDocumentationBuild = process.env.DOCUMENTATION +const isDevelopmentBuild = env.BUILD === 'development' +const isAnalyzeBuild = env.ANALYZE +const isDocumentationBuild = env.DOCUMENTATION const maxWorkers = Math.floor(availableParallelism() / 2)