Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Prevent require()ing executable-only files #789

Copy link
Copy link
@nfischer

Description

@nfischer
Issue body actions

This was a point raised in #786. We can prevent require()ing files with:

if (require.main === module) {
    // everything goes here
}

This might be a good idea for files which we only intend to execute (e.g. bin/shjs).

I would also consider rewriting as:

if (require.main !== module) {
  throw new Error('Module should not be required');
}
// everything goes here

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.