This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
chore(npm): Make modules Browserify compatible #10732
Closed
Closed
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
907dae1
chore(nom): Make modules Browserify compatible
bclinkinbeard 736f6c4
Export module name only
bclinkinbeard 62b538c
chore(npm): Pipe to index.js, duh.
bclinkinbeard 706b0ce
chore(npm): Better way to initialize index.js
bclinkinbeard 156ca4c
chore(npm): Add angular peer dependency where appropriate
bclinkinbeard b4a052d
chore(npm): Handle special case of angular-mocks module(s)
bclinkinbeard 5b5d50c
chore(npm): Remove errant code gen line
bclinkinbeard 24dfc82
chore(npm): Use 2 spaces in package.json, not a tab
bclinkinbeard 8f5bb24
chore(npm): List new utility function
bclinkinbeard e8b9b7a
chore(npm): Remove peerDependencies generation
bclinkinbeard 1916264
Updating to return the module for everything but angular and angular-…
bclinkinbeard b40fe18
Clean up and allowing use of require('angular-mocks/ngMock').name
bclinkinbeard ed8489a
chore(npm): Return module name for all but angular and angular-mocks
bclinkinbeard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -75,6 +75,29 @@ function prepare { | |
replaceJsonProp "bower.json" "angular.*" ".*" "$NEW_VERSION" | ||
replaceJsonProp "package.json" "version" ".*" "$NEW_VERSION" | ||
replaceJsonProp "package.json" "angular.*" ".*" "$NEW_VERSION" | ||
deleteJsonProp "package.json" "main" | ||
|
||
echo "-- Adding CommonJS index file" | ||
if [ -f "index.js" ] | ||
then | ||
rm index.js | ||
fi | ||
|
||
touch index.js | ||
echo "require('./$repo');" >> index.js | ||
echo "" >> index.js | ||
echo "module.exports = $repo;" >> index.js | ||
if [ $repo == "angular" ] | ||
then | ||
echo "module.exports = angular;" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't you need to pipe these echos to index.js with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, thanks! Fixed. |
||
else | ||
# convert to module names (angular-animate >> ngAnimate) | ||
suffix=`echo $repo | cut -c9-` | ||
first=`echo $suffix | cut -c1 | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` | ||
tail=`echo $suffix | cut -c2-` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure to comment these lines clearly to indicate that you're transforming the repo name into a module name, alright? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, good idea. |
||
|
||
echo "module.exports = 'ng$first$tail';" | ||
fi | ||
|
||
git add -A | ||
|
||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of removing index.js, touching it and then appending to it, you could just do this:
echo "require('./$repo');" > index.js
--- that would shave off a few lines of code and be a bit easier to readThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, done.