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

complain

Package Overview
Dependencies
Maintainers
10
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

complain - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

test/development.js

27

index.js

@@ -6,2 +6,3 @@ 'use strict';

var isDevelopment = !env || env === 'dev' || env === 'development';
var showModuleComplains = typeof process !== 'undefined' && Boolean(process.env.SHOW_MODULE_COMPLAINS);
var logger = typeof console !== 'undefined' && console.warn && console;

@@ -22,5 +23,6 @@ var cwd = typeof process !== 'undefined' && process.cwd() + '/' || '';

complain.colors = { warning:'\x1b[31;1m', message:false, location:'\u001b[90m' };
complain.getModuleName = getModuleName;
/* istanbul ignore next */
if(typeof module !== 'undefined' && module.exports) {
if (typeof module !== 'undefined' && module.exports) {
module.exports = complain;

@@ -55,3 +57,16 @@ } else if(typeof window !== 'undefined') {

location = options.location || getLocation(getCallToDeprecate);
var moduleName = complain.getModuleName(location);
if (moduleName && !showModuleComplains) {
if (!hits[moduleName]) {
var output = format('WARNING!!', complain.colors.warning)
output += linebreak + format('The module ['+moduleName+'] is using deprecated features.', complain.colors.message);
output += linebreak + format('Run with process.env.SHOW_MODULE_COMPLAINS=1 to see all warnings.', complain.colors.message);
complain.log(linebreak + output + linebreak);
hits[moduleName] = true;
}
return;
}
/* istanbul ignore next */

@@ -133,3 +148,13 @@ // Location is only missing in older browsers.

function getModuleName(location) {
var locationParts = location.replace(cwd, '').split(/\/|\\/g);
for(var i = locationParts.length-1; i >= 0; i--) {
if (locationParts[i] === 'node_modules') {
var moduleName = locationParts[i+1];
return (moduleName[0] === '@') ? moduleName+'/'+locationParts[i+2] : moduleName;
}
}
}
function noop(){};
function noopReturn(r) { return r; };

2

package.json
{
"name": "complain",
"version": "1.2.0",
"version": "1.3.0",
"description": "Mark methods as deprecated and warn the user when they're called",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -92,4 +92,10 @@ # complain

### complain.getModuleName(location)
The function that determines if a complaint is coming from a `node_module`. If the location for a complaint is inside a dependent module, a single generic warning is logged once per module. You can replace this with your own function for environments (like browsers) that might not have `node_modules` in the path.
> Run with the enviornment variable SHOW_MODULE_COMPLAINS=1 to disable the generic module warning
## license
MIT
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