From e38e73e629722e7306f09fa9ade5ec25cb35e45e Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Wed, 30 Oct 2024 14:08:49 +0100 Subject: [PATCH] Improve postload to not break the Pharo bootstrap --- .../BaselineOfMicrodown.class.st | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index ba2e7d1b..be33d17f 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -147,19 +147,13 @@ BaselineOfMicrodown >> mustache: spec [ { #category : 'baselines' } BaselineOfMicrodown >> postload: loader package: packageSpec [ - | p | - self class name, ' postload ' traceCr. - - p := (IceRepository repositoryNamed: 'microdown'). - p ifNil: [ p := (IceRepository repositoryNamed: 'Microdown') ]. - [ - (p ifNotNil: [ :p2 | (p2 packageNamed: 'BaselineOfMicrodown') reload ]) - ] - on: MCMergeOrLoadWarning - do: [ :ex | ex load ] - - - + "If it is absent it's because we are in the Pharo bootstrap" + self class environment at: #IceRepository ifPresent: [ :class | + | repository | + repository := (class repositoryNamed: 'microdown') ifNil: [ class repositoryNamed: 'Microdown' ]. + [ repository ifNotNil: [ (repository packageNamed: 'BaselineOfMicrodown') reload ] ] + on: MCMergeOrLoadWarning + do: [ :ex | ex load ] ] ] { #category : 'baselines' } @@ -175,21 +169,14 @@ BaselineOfMicrodown >> preload: loader package: packageSpec [ found unload; forget ] ]" - + | packagesToUnload | - self class name, ' preload ' traceCr. - packagesToUnload := ((PackageOrganizer default packages - select: [ :each | each name beginsWith: 'Microdown' ]) collect: [ :each | each name ]) - reject: [ :each | - #('Microdown-RichTextPresenter' 'Microdown-RichTextPresenter-Tests') includes: each ]. + packagesToUnload := ((PackageOrganizer default packages select: [ :each | each name beginsWith: 'Microdown' ]) collect: [ :each | each name ]) reject: [ :each | + #( 'Microdown-RichTextPresenter' 'Microdown-RichTextPresenter-Tests' ) includes: each ]. "these two are not managed by the microdown repo but the documentation. I should rename them in the future to avoid confusion" - packagesToUnload do: - [ :each | - ((IceRepository repositoryNamed: 'Microdown') packageNamed: each) unload ]. - - + packagesToUnload do: [ :each | ((IceRepository repositoryNamed: 'Microdown') packageNamed: each) unload ] ] { #category : 'external projects' }