Skip to content

Error when importing using a different name than "assert" #18

@thevtm

Description

@thevtm

Basically if you name the assert function other than "assert" the regex fails.

const betterAss = require("./index");
betterAss(1 === 2);
~/better-assert/index.js:30
  var src = line.match(/assert\((.*)\)/)[1];
                                        ^

TypeError: Cannot read property '1' of null
    at assert (~/better-assert/index.js:30:41)
    at Object.<anonymous> (~/better-assert/fn-name-test.js:4:1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions