@@ -43,16 +43,16 @@ class Channel {
43
43
}
44
44
}
45
45
46
- void installLatestVersion () {
46
+ Future < void > installLatestVersion () async {
47
47
if (isDownloaded ()) {
48
48
print (orange ('Channel is already installed and the current version is: '
49
49
'$currentVersion ' ));
50
50
} else {
51
- final releases = Release .fetchReleases (name);
51
+ final releases = await Release .fetchReleases (name);
52
52
final version = releases[0 ].version.toString ();
53
53
print ('Installing $name ($version ) ...' );
54
- download (version);
55
- currentVersion = version;
54
+ await download (version);
55
+ await setCurrentVersion ( version) ;
56
56
_createChannelSymlink ();
57
57
print ('Install of $name channel complete.' );
58
58
}
@@ -65,9 +65,9 @@ class Channel {
65
65
_createChannelSymlink ();
66
66
}
67
67
68
- void pin (String version) {
69
- currentVersion = version;
70
- pinned = true ;
68
+ Future < void > pin (String version) async {
69
+ await setCurrentVersion ( version) ;
70
+ await setPinned ( pinned: true ) ;
71
71
72
72
/// If we are the active channel then we need to update the active link.
73
73
if (isActive) {
@@ -76,9 +76,9 @@ class Channel {
76
76
_createChannelSymlink ();
77
77
}
78
78
79
- void unpin () {
80
- currentVersion = latestVersion;
81
- pinned = false ;
79
+ Future < void > unpin () async {
80
+ await setCurrentVersion ( latestVersion) ;
81
+ await setPinned ( pinned: false ) ;
82
82
83
83
/// If we are the active channel then we need to update the active link.
84
84
if (isActive) {
@@ -155,14 +155,14 @@ class Channel {
155
155
/// been downloaded.
156
156
bool isDownloaded () => isVersionCached (currentVersion);
157
157
158
- void download (String version) {
159
- DownloadVersion (name, version, _pathToVersion (version)).download ();
158
+ Future < void > download (String version) async {
159
+ await DownloadVersion (name, version, _pathToVersion (version)).download ();
160
160
}
161
161
162
162
/// Downloads the list of versions available for this channel
163
163
/// and returns the must recent version.
164
- String fetchLatestVersion () {
165
- final releases = Release .fetchReleases (name);
164
+ Future < String > fetchLatestVersion () async {
165
+ final releases = await Release .fetchReleases (name);
166
166
return releases[0 ].version.toString ();
167
167
}
168
168
@@ -174,10 +174,9 @@ class Channel {
174
174
return _version ?? = latestVersion;
175
175
}
176
176
177
- set currentVersion (String version) {
177
+ Future < void > setCurrentVersion (String version) async {
178
178
_settings['currentVersion' ] = version;
179
- // ignore: discarded_futures
180
- waitForEx (_settings.save ());
179
+ await _settings.save ();
181
180
}
182
181
183
182
/// the most recent version we have downloaded.
@@ -192,10 +191,10 @@ class Channel {
192
191
/// If true then this channel is currently pinned.
193
192
bool get pinned => _settings['pinned' ] as bool ? ?? false ;
194
193
195
- set pinned ( bool pinned) {
194
+ Future < void > setPinned ({ required bool pinned}) async {
196
195
_settings['pinned' ] = pinned;
197
196
// ignore: discarded_futures
198
- waitForEx ( _settings.save () );
197
+ await _settings.save ();
199
198
}
200
199
201
200
static String channelPath (String channel) =>
@@ -217,8 +216,8 @@ class Channel {
217
216
/// Shows the user a menu with the 20 most recent version for the channel.
218
217
///
219
218
/// Returns the version the user selected.
220
- Release selectToInstall () {
221
- final releases = Release .fetchReleases (name);
219
+ Future < Release > selectToInstall () async {
220
+ final releases = await Release .fetchReleases (name);
222
221
223
222
final release = menu <Release >('Select Version to install:' ,
224
223
options: releases,
@@ -242,21 +241,21 @@ class Channel {
242
241
bool isVersionCached (String version) =>
243
242
cachedVersions ().any ((element) => basename (element) == version);
244
243
245
- void upgrade () {
244
+ Future < void > upgrade () async {
246
245
if (isPinned) {
247
246
printerr (
248
247
red ('The $name is pinned. Unpin the channel first and try again' ));
249
248
} else {
250
- final version = fetchLatestVersion ();
249
+ final version = await fetchLatestVersion ();
251
250
252
251
if (version == currentVersion) {
253
252
print ('You are already on the latest version ($version ) for the '
254
253
'$name channel' );
255
254
} else {
256
255
print ('Downloading $version ...' );
257
- download (version);
256
+ await download (version);
258
257
259
- currentVersion = version;
258
+ await setCurrentVersion ( version) ;
260
259
261
260
if (isActive) {
262
261
/// if we are the active channel then calling swithTo
0 commit comments