-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7013922
commit 2344bae
Showing
5 changed files
with
61 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'dart:io'; | ||
|
||
Future<void> main() async { | ||
const package = 'fvm'; // Your package name | ||
const destination = | ||
'/usr/local/bin'; // system location for user installed binaries | ||
|
||
// Identify the operating system | ||
var os = Platform.operatingSystem; | ||
|
||
if (os != 'macos' && os != 'linux') { | ||
print('Unsupported OS. Only MacOS and Linux are supported.'); | ||
return; | ||
} | ||
|
||
// Get temporary directory | ||
var tempDir = await Directory.systemTemp.createTemp('fvm-compile'); | ||
|
||
var tempFile = File('${tempDir.path}/$package-$os'); | ||
|
||
// Compile the package to native executable | ||
print('Compiling package...'); | ||
final compileResult = await Process.run( | ||
'dart', | ||
['compile', 'exe', 'bin/fvm.dart', '-o', tempFile.path], | ||
); | ||
|
||
// Error checking for compile process | ||
if (compileResult.exitCode != 0) { | ||
print('Error occurred in compilation:\n ${compileResult.stderr}'); | ||
return; | ||
} | ||
|
||
print('Compilation successful.'); | ||
print('Moving compiled package to destination...'); | ||
|
||
// Move the compiled executable to desired directory | ||
|
||
// Make sure your Dart application has the necessary permissions for this operation | ||
if (await tempFile.exists()) { | ||
await tempFile.rename('$destination/$package'); | ||
print('Executable moved successfully'); | ||
} else { | ||
print('Failed moving the binary. File does not exist.'); | ||
} | ||
|
||
// Clean up the temp directory | ||
await tempDir.delete(); | ||
|
||
// Deactivate current globally activated version of FVM | ||
final deactivateResult = | ||
await Process.run('dart', ['pub', 'global', 'deactivate', 'fvm']); | ||
if (deactivateResult.exitCode == 0) { | ||
print('Deactivated current global version of FVM successfully'); | ||
} else { | ||
print('Error during the deactivation of the global FVM version'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters