Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit c5686c5

Browse files
bclinkinbeardcaitp
authored andcommitted
chore(npm): Make require()-able as part of publish script
(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#10731
1 parent 7fdb54d commit c5686c5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

scripts/bower/publish.sh

+12
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ function prepare {
7575
replaceJsonProp "bower.json""angular.*"".*""$NEW_VERSION"
7676
replaceJsonProp "package.json""version"".*""$NEW_VERSION"
7777
replaceJsonProp "package.json""angular.*"".*""$NEW_VERSION"
78+
deleteJsonProp "package.json""main"
79+
80+
echo"-- Adding CommonJS index file"
81+
if [ -f"index.js" ]
82+
then
83+
rm index.js
84+
fi
85+
86+
touch index.js
87+
echo"require('./$repo');">> index.js
88+
echo"">> index.js
89+
echo"module.exports = $repo;">> index.js
7890

7991
git add -A
8092

scripts/utils.inc

+6
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ function replaceJsonProp {
207207
replaceInFile $1'"('$2')"[ ]*:[ ]*"'$3'"''"\1": "'$4'"'
208208
}
209209

210+
# deleteJsonProp(jsonFile, property)
211+
# - restriction: property needs to be on a single line!
212+
functiondeleteJsonProp {
213+
sed -i'' -e /\"$2\"\:/d $1
214+
}
215+
210216
# replaceInFile(file, findPattern, replacePattern)
211217
functionreplaceInFile {
212218
sed -i.tmp -E"s/$2/$3/" $1

0 commit comments

Comments
 (0)
close