2022-07-25 14:43:45 +00:00
|
|
|
"
|
|
|
|
I'm a helper class modelling the common uses of the Nim's [Nimble package manager](https://github.com/nim-lang/nimble).
|
|
|
|
This was evolved in the context of the [Grafoscopio](mutabit.com/grafoscopio/en.html) community exploration and prototyping of interactive documentation.
|
|
|
|
"
|
|
|
|
Class {
|
|
|
|
#name : #Nimble,
|
|
|
|
#superclass : #Object,
|
|
|
|
#category : #'MiniDocs-MiniDocs'
|
|
|
|
}
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Nimble class >> detect: packageName [
|
|
|
|
^ self installed
|
|
|
|
detect: [ :dependency | dependency beginsWith: packageName ]
|
|
|
|
ifFound: [ ^ true ]
|
|
|
|
ifNone: [ ^ false ]
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Nimble class >> install: packageName [
|
|
|
|
(self detect: packageName) ifTrue: [ ^ self ].
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: 'nimble';
|
|
|
|
arguments: {'install'.
|
|
|
|
packageName};
|
2022-07-25 14:59:41 +00:00
|
|
|
redirectStdout;
|
2022-07-25 14:43:45 +00:00
|
|
|
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Nimble class >> installed [
|
|
|
|
| installed |
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: 'nimble';
|
|
|
|
arguments: #('list' '--installed');
|
|
|
|
redirectStdout;
|
|
|
|
runAndWaitOnExitDo: [ :command :outString | installed := outString ].
|
|
|
|
^ installed lines
|
|
|
|
]
|