add clean command

This commit is contained in:
2025-06-02 08:18:26 -05:00
parent d098800c88
commit 9e45219706

51
scripts/clean.ce Normal file
View File

@@ -0,0 +1,51 @@
// cell clean - Remove build artifacts from modules/
var io = use('io')
log.console(io.searchpath())
if (!io.exists('.cell/build')) {
log.console("No build directory found")
$_.stop()
return
}
log.console("Cleaning build artifacts...")
// Recursively delete directory contents
function remove_dir(path) {
var files = io.enumerate(path, false) // non-recursive first
// Delete all files and subdirectories
for (var i = 0; i < files.length; i++) {
var file = files[i]
if (io.is_directory(file)) {
remove_dir(file) // Recurse into subdirectory
} else {
try {
io.rm(file)
} catch (e) {
log.error("Failed to remove " + file + ": " + e)
}
}
}
// Now remove the empty directory
try {
io.rm(path)
} catch (e) {
log.error("Failed to remove directory " + path + ": " + e)
}
}
// Remove the build directory
try {
remove_dir('.cell/build')
log.console("Build directory removed")
} catch (e) {
log.error("Failed during cleanup: " + e)
}
log.console("Clean complete!")
$_.stop()