path-utils.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
  3. // See LICENSE in the project root for license information.
  4. var __importDefault = (this && this.__importDefault) || function (mod) {
  5. return (mod && mod.__esModule) ? mod : { "default": mod };
  6. };
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.findAndConsoleLogPatchPathCli = findAndConsoleLogPatchPathCli;
  9. exports.getPathToLinterJS = getPathToLinterJS;
  10. exports.ensurePathToGeneratedPatch = ensurePathToGeneratedPatch;
  11. const fs_1 = __importDefault(require("fs"));
  12. const os_1 = __importDefault(require("os"));
  13. const _patch_base_1 = require("../_patch-base");
  14. const constants_1 = require("./constants");
  15. const package_json_1 = __importDefault(require("../../package.json"));
  16. const CURRENT_PACKAGE_VERSION = package_json_1.default.version;
  17. function findAndConsoleLogPatchPathCli() {
  18. const eslintBulkDetectEnvVarValue = process.env[constants_1.ESLINT_BULK_DETECT_ENV_VAR_NAME];
  19. if (eslintBulkDetectEnvVarValue !== 'true' && eslintBulkDetectEnvVarValue !== '1') {
  20. return;
  21. }
  22. const startDelimiter = 'RUSHSTACK_ESLINT_BULK_START';
  23. const endDelimiter = 'RUSHSTACK_ESLINT_BULK_END';
  24. const configuration = {
  25. /**
  26. * `@rushstack/eslint-bulk` should report an error if its package.json is older than this number
  27. */
  28. minCliVersion: '0.0.0',
  29. /**
  30. * `@rushstack/eslint-bulk` will invoke this entry point
  31. */
  32. cliEntryPoint: require.resolve('../exports/eslint-bulk')
  33. };
  34. console.log(startDelimiter + JSON.stringify(configuration) + endDelimiter);
  35. }
  36. function getPathToLinterJS() {
  37. if (!_patch_base_1.eslintFolder) {
  38. throw new Error('Cannot find ESLint installation to patch.');
  39. }
  40. return `${_patch_base_1.eslintFolder}/lib/linter/linter.js`;
  41. }
  42. function ensurePathToGeneratedPatch() {
  43. const patchesFolderPath = `${os_1.default.tmpdir()}/rushstack-eslint-bulk-${CURRENT_PACKAGE_VERSION}/patches`;
  44. fs_1.default.mkdirSync(patchesFolderPath, { recursive: true });
  45. const pathToGeneratedPatch = `${patchesFolderPath}/linter-patch-v${_patch_base_1.eslintPackageVersion}.js`;
  46. return pathToGeneratedPatch;
  47. }
  48. //# sourceMappingURL=path-utils.js.map