New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@parcel/utils

Package Overview
Dependencies
Maintainers
1
Versions
907
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parcel/utils - npm Package Compare versions

Comparing version 2.0.0-nightly.250 to 2.0.0-nightly.252

41

lib/prettyDiagnostic.js

@@ -16,7 +16,7 @@ "use strict";

var _nullthrows = _interopRequireDefault(require("nullthrows"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function prettyDiagnostic(diagnostic) {
var _ref;
async function prettyDiagnostic(diagnostic, options) {
let {

@@ -32,5 +32,10 @@ origin,

} = diagnostic;
if (filePath != null && options && !_path.default.isAbsolute(filePath)) {
filePath = _path.default.join(options.projectRoot, filePath);
}
let result = {
message: (0, _markdownAnsi.default)(`**${origin !== null && origin !== void 0 ? origin : 'unknown'}**: `) + (skipFormatting ? message : (0, _markdownAnsi.default)(message)),
stack: (_ref = stack !== null && stack !== void 0 ? stack : filePath) !== null && _ref !== void 0 ? _ref : '',
stack: '',
codeframe: '',

@@ -41,13 +46,25 @@ hints: []

if (codeFrame !== undefined) {
var _codeFrame$code;
let highlights = Array.isArray(codeFrame.codeHighlights) ? codeFrame.codeHighlights : [codeFrame.codeHighlights];
let formattedCodeFrame = (0, _codeframe.default)(codeFrame.code, highlights, {
useColor: true,
syntaxHighlighting: true,
language: // $FlowFixMe sketchy null checks do not matter here...
language || (filePath ? _path.default.extname(filePath).substr(1) : undefined)
});
result.codeframe += typeof filePath !== 'string' ? '' : _chalk.default.underline(`${filePath}:${highlights[0].start.line}:${highlights[0].start.column}\n`);
result.codeframe += formattedCodeFrame;
let code = (_codeFrame$code = codeFrame.code) !== null && _codeFrame$code !== void 0 ? _codeFrame$code : options && (await options.inputFS.readFile((0, _nullthrows.default)(filePath), 'utf8'));
if (code != null) {
let formattedCodeFrame = (0, _codeframe.default)(code, highlights, {
useColor: true,
syntaxHighlighting: true,
language: // $FlowFixMe sketchy null checks do not matter here...
language || (filePath ? _path.default.extname(filePath).substr(1) : undefined)
});
result.codeframe += typeof filePath !== 'string' ? '' : _chalk.default.underline(`${filePath}:${highlights[0].start.line}:${highlights[0].start.column}\n`);
result.codeframe += formattedCodeFrame;
}
}
if (stack != null) {
result.stack = stack;
} else if (filePath != null && result.codeframe == null) {
result.stack = filePath;
}
if (Array.isArray(hints) && hints.length) {

@@ -54,0 +71,0 @@ result.hints = hints.map(h => {

{
"name": "@parcel/utils",
"version": "2.0.0-nightly.250+d3e9d809",
"version": "2.0.0-nightly.252+3c1c7db9",
"description": "Blazing fast, zero configuration web application bundler",

@@ -20,6 +20,6 @@ "license": "MIT",

"@iarna/toml": "^2.2.0",
"@parcel/codeframe": "2.0.0-nightly.250+d3e9d809",
"@parcel/diagnostic": "2.0.0-nightly.250+d3e9d809",
"@parcel/logger": "2.0.0-nightly.250+d3e9d809",
"@parcel/markdown-ansi": "2.0.0-nightly.250+d3e9d809",
"@parcel/codeframe": "2.0.0-nightly.252+3c1c7db9",
"@parcel/diagnostic": "2.0.0-nightly.252+3c1c7db9",
"@parcel/logger": "2.0.0-nightly.252+3c1c7db9",
"@parcel/markdown-ansi": "2.0.0-nightly.252+3c1c7db9",
"@parcel/source-map": "2.0.0-alpha.4.9",

@@ -45,3 +45,3 @@ "ansi-html": "^0.0.7",

},
"gitHead": "d3e9d8093c0d5848d1a01469ffa9f0ff77b604e4"
"gitHead": "3c1c7db9559771af7df9f39ead4513b56afd3c9b"
}
// @flow strict-local
import type {Diagnostic} from '@parcel/diagnostic';
import type {PluginOptions} from '@parcel/types';

@@ -8,2 +9,3 @@ import formatCodeFrame from '@parcel/codeframe';

import path from 'path';
import nullthrows from 'nullthrows';

@@ -17,5 +19,6 @@ export type AnsiDiagnosticResult = {|

export default function prettyDiagnostic(
export default async function prettyDiagnostic(
diagnostic: Diagnostic,
): AnsiDiagnosticResult {
options?: PluginOptions,
): Promise<AnsiDiagnosticResult> {
let {

@@ -32,2 +35,6 @@ origin,

if (filePath != null && options && !path.isAbsolute(filePath)) {
filePath = path.join(options.projectRoot, filePath);
}
let result = {

@@ -37,3 +44,3 @@ message:

(skipFormatting ? message : mdAnsi(message)),
stack: stack ?? filePath ?? '',
stack: '',
codeframe: '',

@@ -48,19 +55,32 @@ hints: [],

let formattedCodeFrame = formatCodeFrame(codeFrame.code, highlights, {
useColor: true,
syntaxHighlighting: true,
language:
// $FlowFixMe sketchy null checks do not matter here...
language || (filePath ? path.extname(filePath).substr(1) : undefined),
});
let code =
codeFrame.code ??
(options &&
(await options.inputFS.readFile(nullthrows(filePath), 'utf8')));
result.codeframe +=
typeof filePath !== 'string'
? ''
: chalk.underline(
`${filePath}:${highlights[0].start.line}:${highlights[0].start.column}\n`,
);
result.codeframe += formattedCodeFrame;
if (code != null) {
let formattedCodeFrame = formatCodeFrame(code, highlights, {
useColor: true,
syntaxHighlighting: true,
language:
// $FlowFixMe sketchy null checks do not matter here...
language || (filePath ? path.extname(filePath).substr(1) : undefined),
});
result.codeframe +=
typeof filePath !== 'string'
? ''
: chalk.underline(
`${filePath}:${highlights[0].start.line}:${highlights[0].start.column}\n`,
);
result.codeframe += formattedCodeFrame;
}
}
if (stack != null) {
result.stack = stack;
} else if (filePath != null && result.codeframe == null) {
result.stack = filePath;
}
if (Array.isArray(hints) && hints.length) {

@@ -67,0 +87,0 @@ result.hints = hints.map(h => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc