Skip to content

Commit

Permalink
Merge pull request #1508 from stealjs/main-forward-slash
Browse files Browse the repository at this point in the history
Support the forward slash behavior in pkg.main
  • Loading branch information
matthewp committed Sep 5, 2019
2 parents f9b7e99 + d8891bc commit 1350506
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ext/npm-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,11 @@ var utils = {
} else if(typeof pkg.jam === "object" && pkg.jam.main) {
main = pkg.jam.main;
} else if(pkg.main) {
main = pkg.main;
if(utils.path.endsWithSlash(pkg.main)) {
main = pkg.main + "index";
} else {
main = pkg.main;
}
} else {
main = "index";
}
Expand Down
5 changes: 5 additions & 0 deletions test/npm/normalize_main-config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ var mainVariations = {
pkg.main = "bar.js";
},

"pkg.main with trailing slash": function(pkg) {
pkg.main = "bar/";
return "bar/index";
},

"browser string": function(pkg){
pkg.browser = "bar.js";
},
Expand Down

0 comments on commit 1350506

Please sign in to comment.