| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|---|
| 2 | // See LICENSE in the project root for license information.
|
|---|
| 3 | import fs from 'node:fs';
|
|---|
| 4 | import os from 'node:os';
|
|---|
| 5 | import { eslintFolder, eslintPackageVersion } from '../_patch-base';
|
|---|
| 6 | import { ESLINT_BULK_DETECT_ENV_VAR_NAME, ESLINT_BULK_STDOUT_END_DELIMETER, ESLINT_BULK_STDOUT_START_DELIMETER } from './constants';
|
|---|
| 7 | import currentPackageJson from '../../package.json';
|
|---|
| 8 | const CURRENT_PACKAGE_VERSION = currentPackageJson.version;
|
|---|
| 9 | export function findAndConsoleLogPatchPathCli() {
|
|---|
| 10 | const eslintBulkDetectEnvVarValue = process.env[ESLINT_BULK_DETECT_ENV_VAR_NAME];
|
|---|
| 11 | if (eslintBulkDetectEnvVarValue !== 'true' && eslintBulkDetectEnvVarValue !== '1') {
|
|---|
| 12 | return;
|
|---|
| 13 | }
|
|---|
| 14 | const configuration = {
|
|---|
| 15 | /**
|
|---|
| 16 | * `@rushstack/eslint-bulk` should report an error if its package.json is older than this number
|
|---|
| 17 | */
|
|---|
| 18 | minCliVersion: '0.0.0',
|
|---|
| 19 | /**
|
|---|
| 20 | * `@rushstack/eslint-bulk` will invoke this entry point
|
|---|
| 21 | */
|
|---|
| 22 | cliEntryPoint: require.resolve('../exports/eslint-bulk')
|
|---|
| 23 | };
|
|---|
| 24 | console.log(ESLINT_BULK_STDOUT_START_DELIMETER + JSON.stringify(configuration) + ESLINT_BULK_STDOUT_END_DELIMETER);
|
|---|
| 25 | }
|
|---|
| 26 | export function getPathToLinterJS() {
|
|---|
| 27 | if (!eslintFolder) {
|
|---|
| 28 | throw new Error('Cannot find ESLint installation to patch.');
|
|---|
| 29 | }
|
|---|
| 30 | return `${eslintFolder}/lib/linter/linter.js`;
|
|---|
| 31 | }
|
|---|
| 32 | export function ensurePathToGeneratedPatch() {
|
|---|
| 33 | const patchesFolderPath = `${os.tmpdir()}/rushstack-eslint-bulk-${CURRENT_PACKAGE_VERSION}/patches`;
|
|---|
| 34 | fs.mkdirSync(patchesFolderPath, { recursive: true });
|
|---|
| 35 | const pathToGeneratedPatch = `${patchesFolderPath}/linter-patch-v${eslintPackageVersion}.js`;
|
|---|
| 36 | return pathToGeneratedPatch;
|
|---|
| 37 | }
|
|---|
| 38 | //# sourceMappingURL=path-utils.js.map |
|---|