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

chore(npm): Make require()-able as part of publish script #10731

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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