Skip to content

Commit 5ad4baa

Browse files
committed
Ensure that the project can be sorted topologically before publishing
1 parent 24891b1 commit 5ad4baa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/scripts/npm_publish

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@ check_licenses() {
194194
return 0
195195
}
196196

197+
# Checks that the project can be sorted topologically.
198+
check_toposort() {
199+
echo 'Performing a topological sort...' >&2
200+
make list-pkgs-toposort >/dev/null
201+
if [[ "$?" -ne 0 ]]; then
202+
echo '' >&2
203+
echo 'Error: unexpected error. Unable to perform a topological sort. This is likely due to a dependency cycle. Please resolve before publishing. Command: make list-pkgs-toposort.' >&2
204+
echo '' >&2
205+
return 1
206+
fi
207+
echo 'Successfully performed a topological sort.' >&2
208+
echo '' >&2
209+
return 0
210+
}
211+
197212
# Updates package meta data.
198213
update_package_meta_data() {
199214
echo 'Updating package meta data...' >&2
@@ -529,6 +544,10 @@ main() {
529544
if [[ "$?" -ne 0 ]]; then
530545
on_error 1
531546
fi
547+
check_toposort
548+
if [[ "$?" -ne 0 ]]; then
549+
on_error 1
550+
fi
532551
update_package_meta_data
533552
if [[ "$?" -ne 0 ]]; then
534553
revert_changes

0 commit comments

Comments
 (0)