Skip to content

Commit

Permalink
chore(npm): Make require()-able as part of publish script
Browse files Browse the repository at this point in the history
(This has not been tested locally with browserify --- but it should work!
If it doesn't, please file a bug rather than just leaving a comment on this
commit :)

Closes angular#10731
  • Loading branch information
bclinkinbeard authored and caitp committed Jan 13, 2015
1 parent ba90261 commit babc20b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scripts/bower/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ 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

git add -A

Expand Down
6 changes: 6 additions & 0 deletions scripts/utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ function replaceJsonProp {
replaceInFile $1 '"('$2')"[ ]*:[ ]*"'$3'"' '"\1": "'$4'"'
}

# deleteJsonProp(jsonFile, property)
# - restriction: property needs to be on a single line!
function deleteJsonProp {
sed -i '' -e /\"$2\"\:/d $1
}

# replaceInFile(file, findPattern, replacePattern)
function replaceInFile {
sed -i .tmp -E "s/$2/$3/" $1
Expand Down

0 comments on commit babc20b

Please sign in to comment.