Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@poi/dev-utils

Package Overview
Dependencies
Maintainers
3
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poi/dev-utils - npm Package Compare versions

Comparing version 10.0.0 to 10.0.1

79

formatWebpackMessages.js

@@ -10,3 +10,3 @@ /* eslint-disable */

'use strict'
'use strict';

@@ -20,8 +20,8 @@ // WARNING: this code is untranspiled and is used in browser too.

const chalk = require('chalk')
var chalk = require('chalk');
const friendlySyntaxErrorLabel = 'Syntax error:'
var friendlySyntaxErrorLabel = 'Syntax error:';
function isLikelyASyntaxError(message) {
return message.indexOf(friendlySyntaxErrorLabel) !== -1
return message.indexOf(friendlySyntaxErrorLabel) !== -1;
}

@@ -32,7 +32,7 @@

function formatMessage(message, isError) {
let lines = message.split('\n')
var lines = message.split('\n');
if (lines.length > 2 && lines[1] === '') {
// Remove extra newline.
lines.splice(1, 1)
lines.splice(1, 1);
}

@@ -46,6 +46,6 @@

if (lines[0].lastIndexOf('!') !== -1) {
lines[0] = lines[0].substr(lines[0].lastIndexOf('!') + 1)
lines[0] = lines[0].substr(lines[0].lastIndexOf('!') + 1);
}
lines = lines.filter(line => {
lines = lines.filter(function (line) {
// Webpack adds a list of entry points to warning messages:

@@ -56,4 +56,4 @@ // @ ./src/index.js

// It is only useful for syntax errors but we have beautiful frames for them.
return line.indexOf(' @ ') !== 0
})
return line.indexOf(' @ ') !== 0;
});

@@ -63,3 +63,3 @@ // line #0 is filename

if (!lines[0] || !lines[1]) {
return lines.join('\n')
return lines.join('\n');
}

@@ -69,11 +69,5 @@

if (lines[1].indexOf('Module not found: ') === 0) {
lines = [
lines[0],
// Clean up message because "Module not found: " is descriptive enough.
lines[1]
.replace('Cannot resolve \'file\' or \'directory\' ', '')
.replace('Cannot resolve module ', '')
.replace('Error: ', '')
.replace('[CaseSensitivePathsPlugin] ', '')
]
lines = [lines[0],
// Clean up message because "Module not found: " is descriptive enough.
lines[1].replace('Cannot resolve \'file\' or \'directory\' ', '').replace('Cannot resolve module ', '').replace('Error: ', '').replace('[CaseSensitivePathsPlugin] ', '')];
}

@@ -83,6 +77,3 @@

if (lines[1].indexOf('Module build failed: ') === 0) {
lines[1] = lines[1].replace(
'Module build failed: SyntaxError:',
friendlySyntaxErrorLabel
)
lines[1] = lines[1].replace('Module build failed: SyntaxError:', friendlySyntaxErrorLabel);
}

@@ -92,14 +83,11 @@

// TODO: we should really send a PR to Webpack for this.
const exportError = /\s*(.+?)\s*(")?export '(.+?)' was not found in '(.+?)'/
var exportError = /\s*(.+?)\s*(")?export '(.+?)' was not found in '(.+?)'/;
if (lines[1].match(exportError)) {
lines[1] = lines[1].replace(
exportError,
'$1 \'$4\' does not contain an export named \'$3\'.'
)
lines[1] = lines[1].replace(exportError, '$1 \'$4\' does not contain an export named \'$3\'.');
}
lines[0] = chalk.inverse(lines[0])
lines[0] = chalk.inverse(lines[0]);
// Reassemble the message.
message = lines.join('\n')
message = lines.join('\n');
// Internal stacks are generally useless so we strip them... with the

@@ -109,21 +97,18 @@ // exception of stacks containing `webpack:` because they're normally

// https://github.com/facebookincubator/create-react-app/pull/1050
message = message.replace(
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
''
) // at ... ...:x:y
message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, ''); // at ... ...:x:y
return message.trim()
return message.trim();
}
function formatWebpackMessages(json) {
const formattedErrors = json.errors.map(message => {
return formatMessage(message, true)
})
const formattedWarnings = json.warnings.map(message => {
return formatMessage(message, false)
})
const result = {
var formattedErrors = json.errors.map(function (message) {
return formatMessage(message, true);
});
var formattedWarnings = json.warnings.map(function (message) {
return formatMessage(message, false);
});
var result = {
errors: formattedErrors,
warnings: formattedWarnings
}
};
if (result.errors.some(isLikelyASyntaxError)) {

@@ -133,7 +118,7 @@ // If there are any syntax errors, show just them.

// preceding a much more useful Babel syntax error.
result.errors = result.errors.filter(isLikelyASyntaxError)
result.errors = result.errors.filter(isLikelyASyntaxError);
}
return result
return result;
}
module.exports = formatWebpackMessages
module.exports = formatWebpackMessages;
{
"name": "@poi/dev-utils",
"version": "10.0.0",
"version": "10.0.1",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

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