-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
patchStackTrace
export; test that all named exports are detecte…
…d by Node (#5411)
- Loading branch information
1 parent
4f36552
commit 6b4f166
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
return if window? or testingBrowser? | ||
|
||
{EventEmitter} = require 'events' | ||
{join} = require 'path' | ||
{cwd} = require 'process' | ||
{pathToFileURL} = require 'url' | ||
|
||
|
||
packageEntryPath = join cwd(), 'lib/coffeescript/index.js' | ||
packageEntryUrl = pathToFileURL packageEntryPath | ||
|
||
|
||
test "the coffeescript package exposes all members as named exports in Node", -> | ||
|
||
requiredPackage = require packageEntryPath | ||
requiredKeys = Object.keys requiredPackage | ||
|
||
importedPackage = await import(packageEntryUrl) | ||
importedKeys = new Set Object.keys(importedPackage) | ||
|
||
# In `command.coffee`, CoffeeScript extends a `new EventEmitter`; | ||
# we want to ignore these additional added keys. | ||
eventEmitterKeys = new Set Object.getOwnPropertyNames(Object.getPrototypeOf(new EventEmitter)) | ||
|
||
for key in requiredKeys when not eventEmitterKeys.has(key) | ||
# Use `eq` test so that missing keys have their names printed in the error message. | ||
eq (if importedKeys.has(key) then key else undefined), key |