set makefile for windows, macos, linux
This commit is contained in:
parent
ca543c10b7
commit
25d61bc6a2
20
Makefile
20
Makefile
@ -3,11 +3,6 @@ build:
|
|||||||
v -o flist .
|
v -o flist .
|
||||||
sudo ./flist install
|
sudo ./flist install
|
||||||
|
|
||||||
build-win:
|
|
||||||
v fmt -w flist.v
|
|
||||||
v -o flist .
|
|
||||||
./flist.exe install
|
|
||||||
|
|
||||||
rebuild:
|
rebuild:
|
||||||
sudo rm flist
|
sudo rm flist
|
||||||
sudo flist uninstall
|
sudo flist uninstall
|
||||||
@ -18,3 +13,18 @@ rebuild:
|
|||||||
delete:
|
delete:
|
||||||
sudo rm flist
|
sudo rm flist
|
||||||
sudo flist uninstall
|
sudo flist uninstall
|
||||||
|
|
||||||
|
build-win:
|
||||||
|
v fmt -w flist.v
|
||||||
|
v -o flist .
|
||||||
|
./flist.exe install
|
||||||
|
|
||||||
|
rebuild-win:
|
||||||
|
./flist.exe uninstall
|
||||||
|
v fmt -w flist.v
|
||||||
|
v -o flist .
|
||||||
|
./flist.exe install
|
||||||
|
|
||||||
|
delete-win:
|
||||||
|
./flist.exe uninstall
|
||||||
|
|
||||||
|
30
flist.v
30
flist.v
@ -57,12 +57,16 @@ fn remove_path_windows() {
|
|||||||
path_to_remove := r'C:\Program Files\flist'
|
path_to_remove := r'C:\Program Files\flist'
|
||||||
|
|
||||||
// Get the current PATH environment variable
|
// Get the current PATH environment variable
|
||||||
mut current_path := os.getenv('PATH')
|
current_path := os.getenv('PATH')
|
||||||
|
|
||||||
// Remove the specified path from current PATH
|
// Check if the path_to_remove is in the current PATH
|
||||||
paths := current_path.split(';')
|
if !current_path.contains(path_to_remove) {
|
||||||
updated_paths := paths.filter(it != path_to_remove) // Keep only paths that are not the one we want to remove
|
println('The directory is not in the PATH.')
|
||||||
new_env_path := updated_paths.join(';') // Join the remaining paths back into a single string
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove specified directory from the PATH
|
||||||
|
new_env_path := current_path.split(';').filter(it != path_to_remove).join(';')
|
||||||
|
|
||||||
// Prepare the command to set the new PATH
|
// Prepare the command to set the new PATH
|
||||||
cmd := 'setx PATH "${new_env_path}"'
|
cmd := 'setx PATH "${new_env_path}"'
|
||||||
@ -135,12 +139,28 @@ fn install() {
|
|||||||
|
|
||||||
fn uninstall() {
|
fn uninstall() {
|
||||||
info_message('Uninstalling Flist CLI...')
|
info_message('Uninstalling Flist CLI...')
|
||||||
|
|
||||||
if os.exists(binary_location) {
|
if os.exists(binary_location) {
|
||||||
|
// Remove the binary file
|
||||||
os.rm(binary_location) or { panic(err) }
|
os.rm(binary_location) or { panic(err) }
|
||||||
success_message('Flist CLI has been removed from ' + binary_location)
|
success_message('Flist CLI has been removed from ' + binary_location)
|
||||||
|
|
||||||
|
// Get the directory of the binary
|
||||||
|
parent_dir := os.dir(binary_location)
|
||||||
|
|
||||||
|
// Check if the parent directory is empty
|
||||||
|
if os.is_dir_empty(parent_dir) {
|
||||||
|
// Remove the parent directory
|
||||||
|
os.rmdir(parent_dir) or { panic(err) }
|
||||||
|
success_message('The directory ' + parent_dir + ' has been removed as it is empty.')
|
||||||
|
} else {
|
||||||
|
info_message('The directory ' + parent_dir + ' is not empty, so it was not removed.')
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
info_message('Flist CLI is not installed at ' + binary_location)
|
info_message('Flist CLI is not installed at ' + binary_location)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uncomment the following block if you want to remove from PATH for Windows.
|
||||||
// if os.user_os() == 'windows' {
|
// if os.user_os() == 'windows' {
|
||||||
// remove_path_windows()
|
// remove_path_windows()
|
||||||
// }
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user