|
1 | 1 | import { createHash, timingSafeEqual } from 'node:crypto';
|
2 | 2 | import { createWriteStream, readFile } from 'node:fs';
|
3 |
| -import { platform } from 'node:os'; |
| 3 | +import { platform, arch as nodeArch } from 'node:os'; |
| 4 | +import { platform as nodePlatform, release, config } from 'node:process'; |
4 | 5 | import { promisify } from 'node:util';
|
5 | 6 | import { getInput } from '@actions/core';
|
6 | 7 | import arch from 'arch';
|
@@ -274,13 +275,31 @@ export function getSupportedEnvironmentInfo() {
|
274 | 275 | };
|
275 | 276 |
|
276 | 277 | return {
|
| 278 | + /** Returns `true` if the CodeClimate test reporter is actually supported on this environment. */ |
277 | 279 | supported: !UNSUPPORTED_ENVIRONMENTS.some((e) => {
|
278 | 280 | return (
|
279 | 281 | e.architecture === currentEnvironment.architecture &&
|
280 | 282 | e.platform === currentEnvironment.platform
|
281 | 283 | );
|
282 | 284 | }),
|
| 285 | + /** The platform that the action is running on. */ |
283 | 286 | platform: currentEnvironment.platform,
|
| 287 | + /** The CPU architecture that the action is running on. */ |
284 | 288 | architecture: currentEnvironment.architecture,
|
| 289 | + /** The platform that the current Node.js binary was compiled for. */ |
| 290 | + nodePlatform: nodePlatform, |
| 291 | + /** The CPU architecture that the current Node.js binary was compiled for. */ |
| 292 | + nodeArchitecture: nodeArch, |
| 293 | + /** The CPU architecture of the host machine that compiled the current Node.js binary. */ |
| 294 | + nodeHostArchitecture: config.variables.host_arch, |
| 295 | + nodeRelease: release, |
285 | 296 | };
|
286 | 297 | }
|
| 298 | + |
| 299 | +/** |
| 300 | + * Detects if the logic is being currently executed inside a `tap` test. |
| 301 | + */ |
| 302 | +export function amICurrentlyBeingTestedByTap() { |
| 303 | + // REFER: https://node-tap.org/environment/#environment-variables-used-by-tap |
| 304 | + return Object.prototype.hasOwnProperty.call(process.env, 'TAP_CHILD_ID'); |
| 305 | +} |
0 commit comments