@rushstack/node-core-library
Advanced tools
Comparing version 3.45.7 to 3.46.0
@@ -14,2 +14,3 @@ /** | ||
export { ExecutableStdioStreamMapping, ExecutableStdioMapping, IExecutableResolveOptions, IExecutableSpawnSyncOptions, IExecutableSpawnOptions, Executable } from './Executable'; | ||
export { IFileErrorOptions, IFileErrorFormattingOptions, FileError } from './FileError'; | ||
export { INodePackageJson, IPackageJson, IPackageJsonDependencyTable, IPackageJsonScriptTable, IPackageJsonRepository } from './IPackageJson'; | ||
@@ -26,3 +27,3 @@ export { Import, IImportResolveOptions, IImportResolveModuleOptions, IImportResolvePackageOptions } from './Import'; | ||
export { PackageName, PackageNameParser, IPackageNameParserOptions, IParsedPackageName, IParsedPackageNameOrError } from './PackageName'; | ||
export { Path, IPathFormatConciselyOptions } from './Path'; | ||
export { Path, FileLocationStyle, IPathFormatFileLocationOptions, IPathFormatConciselyOptions } from './Path'; | ||
export { Encoding, Text, NewlineKind } from './Text'; | ||
@@ -29,0 +30,0 @@ export { Sort } from './Sort'; |
@@ -5,3 +5,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TypeUuid = exports.StringBufferTerminalProvider = exports.ConsoleTerminalProvider = exports.TerminalProviderSeverity = exports.TextAttribute = exports.ColorValue = exports.Colors = exports.Terminal = exports.StringBuilder = exports.LegacyAdapters = exports.FileWriter = exports.FileSystem = exports.AlreadyExistsBehavior = exports.Sort = exports.NewlineKind = exports.Text = exports.Encoding = exports.Path = exports.PackageNameParser = exports.PackageName = exports.PackageJsonLookup = exports.ProtectableMap = exports.PosixModeBits = exports.MapExtensions = exports.LockFile = exports.JsonSchema = exports.JsonFile = exports.InternalError = exports.Import = exports.Executable = exports.EnvironmentMap = exports.Enum = exports.FolderConstants = exports.FileConstants = exports.Async = exports.AnsiEscape = exports.AlreadyReportedError = void 0; | ||
exports.TypeUuid = exports.StringBufferTerminalProvider = exports.ConsoleTerminalProvider = exports.TerminalProviderSeverity = exports.TextAttribute = exports.ColorValue = exports.Colors = exports.Terminal = exports.StringBuilder = exports.LegacyAdapters = exports.FileWriter = exports.FileSystem = exports.AlreadyExistsBehavior = exports.Sort = exports.NewlineKind = exports.Text = exports.Encoding = exports.Path = exports.PackageNameParser = exports.PackageName = exports.PackageJsonLookup = exports.ProtectableMap = exports.PosixModeBits = exports.MapExtensions = exports.LockFile = exports.JsonSchema = exports.JsonFile = exports.InternalError = exports.Import = exports.FileError = exports.Executable = exports.EnvironmentMap = exports.Enum = exports.FolderConstants = exports.FileConstants = exports.Async = exports.AnsiEscape = exports.AlreadyReportedError = void 0; | ||
/** | ||
@@ -27,2 +27,4 @@ * Core libraries that every NodeJS toolchain project should use. | ||
Object.defineProperty(exports, "Executable", { enumerable: true, get: function () { return Executable_1.Executable; } }); | ||
var FileError_1 = require("./FileError"); | ||
Object.defineProperty(exports, "FileError", { enumerable: true, get: function () { return FileError_1.FileError; } }); | ||
var Import_1 = require("./Import"); | ||
@@ -29,0 +31,0 @@ Object.defineProperty(exports, "Import", { enumerable: true, get: function () { return Import_1.Import; } }); |
/** | ||
* The format that the FileError message should conform to. The supported formats are: | ||
* - Unix: `<path>:<line>:<column> - <message>` | ||
* - VisualStudio: `<path>(<line>,<column>) - <message>` | ||
* | ||
* @public | ||
*/ | ||
export declare type FileLocationStyle = 'Unix' | 'VisualStudio'; | ||
/** | ||
* Options for {@link Path.formatFileLocation}. | ||
* @public | ||
*/ | ||
export interface IPathFormatFileLocationOptions { | ||
/** | ||
* The base path to use when converting `pathToFormat` to a relative path. If not specified, | ||
* `pathToFormat` will be used as-is. | ||
*/ | ||
baseFolder?: string; | ||
/** | ||
* The path that will be used to specify the file location. | ||
*/ | ||
pathToFormat: string; | ||
/** | ||
* The message related to the file location. | ||
*/ | ||
message: string; | ||
/** | ||
* The style of file location formatting to use. | ||
*/ | ||
format: FileLocationStyle; | ||
/** | ||
* The optional line number. If not specified, the line number will not be included | ||
* in the formatted string. | ||
*/ | ||
line?: number; | ||
/** | ||
* The optional column number. If not specified, the column number will not be included | ||
* in the formatted string. | ||
*/ | ||
column?: number; | ||
} | ||
/** | ||
* Options for {@link Path.formatConcisely}. | ||
@@ -63,2 +104,11 @@ * @public | ||
/** | ||
* Formats a file location to look nice for reporting purposes. | ||
* @remarks | ||
* If `pathToFormat` is under the `baseFolder`, then it will be converted to a relative with the `./` prefix. | ||
* Otherwise, it will be converted to an absolute path. | ||
* | ||
* Backslashes will be converted to slashes, unless the path starts with an OS-specific string like `C:\`. | ||
*/ | ||
static formatFileLocation(options: IPathFormatFileLocationOptions): string; | ||
/** | ||
* Replaces Windows-style backslashes with POSIX-style slashes. | ||
@@ -65,0 +115,0 @@ * |
@@ -97,2 +97,52 @@ "use strict"; | ||
/** | ||
* Formats a file location to look nice for reporting purposes. | ||
* @remarks | ||
* If `pathToFormat` is under the `baseFolder`, then it will be converted to a relative with the `./` prefix. | ||
* Otherwise, it will be converted to an absolute path. | ||
* | ||
* Backslashes will be converted to slashes, unless the path starts with an OS-specific string like `C:\`. | ||
*/ | ||
static formatFileLocation(options) { | ||
const { message, format, pathToFormat, baseFolder, line, column } = options; | ||
// Convert the path to be relative to the base folder, if specified. Otherwise, use | ||
// the path as-is. | ||
const filePath = baseFolder | ||
? Path.formatConcisely({ | ||
pathToConvert: pathToFormat, | ||
baseFolder | ||
}) | ||
: path.resolve(pathToFormat); | ||
let formattedFileLocation; | ||
switch (format) { | ||
case 'Unix': { | ||
if (line !== undefined && column !== undefined) { | ||
formattedFileLocation = `:${line}:${column}`; | ||
} | ||
else if (line !== undefined) { | ||
formattedFileLocation = `:${line}`; | ||
} | ||
else { | ||
formattedFileLocation = ''; | ||
} | ||
break; | ||
} | ||
case 'VisualStudio': { | ||
if (line !== undefined && column !== undefined) { | ||
formattedFileLocation = `(${line},${column})`; | ||
} | ||
else if (line !== undefined) { | ||
formattedFileLocation = `(${line})`; | ||
} | ||
else { | ||
formattedFileLocation = ''; | ||
} | ||
break; | ||
} | ||
default: { | ||
throw new Error(`Unknown format: ${format}`); | ||
} | ||
} | ||
return `${filePath}${formattedFileLocation} - ${message}`; | ||
} | ||
/** | ||
* Replaces Windows-style backslashes with POSIX-style slashes. | ||
@@ -99,0 +149,0 @@ * |
{ | ||
"name": "@rushstack/node-core-library", | ||
"version": "3.45.7", | ||
"version": "3.46.0", | ||
"description": "Core libraries that every NodeJS toolchain project should use", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
976167
149
12868
6
0