Skip to content

Commit

Permalink
[Fix] handle exports with an array RHS
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 15, 2023
1 parent ee5bade commit 32d8fa3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var spawn = require('child_process').spawn;
var flatMap = require('array.prototype.flatmap');
var keys = require('object-keys');
var includes = require('array-includes');
var inspect = require('object-inspect');

var args = process.argv.slice(2); // remove node, and script name

Expand Down Expand Up @@ -175,7 +176,9 @@ var validateModule = function validateAPIModule(t, nameOrFilePaths) {
st.deepEqual(keysToCheck, expectedKeys, 'expected entrypoints are present in the proper order');

keysToCheck.forEach(function (key) {
st.ok(fs.existsSync(pkg.exports[key]), 'entrypoint "' + key + '" points to "' + pkg.exports[key] + '" which exists');
var rhs = pkg.exports[key];
var exists = [].concat(rhs).some(fs.existsSync);
st.ok(exists, 'entrypoint "' + key + '" points to "' + inspect(rhs) + '" which exists (or is an array with one item that exists)');
});

st.equal(pkg.exports['./package.json'], './package.json', 'package.json is exposed');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"dependencies": {
"array-includes": "^3.1.6",
"array.prototype.flatmap": "^1.3.1",
"object-inspect": "^1.12.3",
"object-keys": "^1.1.1",
"tape": "^5.6.3"
},
Expand Down

0 comments on commit 32d8fa3

Please sign in to comment.