@frontity/error
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -23,3 +23,3 @@ import { warn, error } from ".."; | ||
console.error = jest.fn(); | ||
error("This is wrong", false); | ||
expect(() => error("This is wrong", { throw: false })).not.toThrow(); | ||
expect(console.error).toHaveBeenCalledTimes(1); | ||
@@ -30,2 +30,10 @@ expect(console.error).toHaveBeenLastCalledWith( | ||
}); | ||
test("In production, console.error the short message", () => { | ||
process.env.NODE_ENV = "production"; | ||
console.error = jest.fn(); | ||
expect(() => error("This is wrong", { throw: false })).not.toThrow(); | ||
expect(console.error).toHaveBeenCalledTimes(1); | ||
expect(console.error).toHaveBeenLastCalledWith("This is wrong"); | ||
}); | ||
}); | ||
@@ -32,0 +40,0 @@ |
12
index.ts
const suffix = "\nVisit https://community.frontity.org for help! 🙂\n"; | ||
export const error = (message: string, doThrow = true) => { | ||
interface FrontityError { | ||
( | ||
message: string, | ||
options?: { | ||
throw?: boolean; | ||
} | ||
): void; | ||
} | ||
export const error: FrontityError = (message, options = {}) => { | ||
const doThrow = typeof options.throw !== "undefined" ? options.throw : true; | ||
if (process.env.NODE_ENV !== "production") { | ||
@@ -5,0 +15,0 @@ if (doThrow) throw new Error(message + suffix); |
{ | ||
"name": "@frontity/error", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Frontity errors and warnings", | ||
@@ -9,6 +9,6 @@ "keywords": [ | ||
"homepage": "https://frontity.org", | ||
"bugs": { | ||
"url": "https://github.com/frontity/frontity/issues" | ||
}, | ||
"license": "Apache-2.0", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
@@ -21,6 +21,3 @@ "type": "git", | ||
"test:inspect": "node --inspect ../../node_modules/.bin/jest --watch --no-cache --runInBand" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/frontity/frontity/issues" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
3670
6
74
1