From 824c7c0e8dcc859a0a3d6f7f55b9cda352c2a806 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sun, 19 Jun 2022 09:42:25 +0800 Subject: [PATCH] refactor: clean script --- frontend/.vscode/tasks.json | 22 +++++--------------- frontend/scripts/clean.cmd | 8 -------- frontend/scripts/clean.sh | 16 --------------- frontend/scripts/makefile/tool.toml | 32 +++++++++++++++++------------ 4 files changed, 24 insertions(+), 54 deletions(-) delete mode 100644 frontend/scripts/clean.cmd delete mode 100644 frontend/scripts/clean.sh diff --git a/frontend/.vscode/tasks.json b/frontend/.vscode/tasks.json index 34df46ad3e..1ff2ff2874 100644 --- a/frontend/.vscode/tasks.json +++ b/frontend/.vscode/tasks.json @@ -10,13 +10,13 @@ // ${cwd}: the current working directory of the spawned process "tasks": [ { - "label": "AF: Clean + Rebuild All", + "label": "AF: Rust Clean + Rebuild All", "type": "shell", "dependsOrder": "sequence", "dependsOn": [ - "AF: Clean", - "AF: build_flowy_sdk", + "AF: Rust Clean", "AF: Flutter Clean", + "AF: build_flowy_sdk", "AF: Flutter Pub Get", "AF: Flutter Package Get", "AF: Generate Language Files", @@ -139,21 +139,9 @@ } }, { - "label": "AF: Clean", + "label": "AF: Rust Clean", "type": "shell", - "command": "sh ./scripts/clean.sh", - "windows": { - "options": { - "shell": { - "executable": "cmd.exe", - "args": [ - "/d", - "/c", - ".\\scripts\\clean.cmd" - ] - } - } - }, + "command": "cargo make rust_clean", "group": "build", "options": { "cwd": "${workspaceFolder}" diff --git a/frontend/scripts/clean.cmd b/frontend/scripts/clean.cmd deleted file mode 100644 index 46cf54e69c..0000000000 --- a/frontend/scripts/clean.cmd +++ /dev/null @@ -1,8 +0,0 @@ -cd rust-lib -cargo clean - -cd ../../shared-lib - -if exist "lib-infra/.cache" ( - rmdir /s/q "lib-infra/.cache" -) \ No newline at end of file diff --git a/frontend/scripts/clean.sh b/frontend/scripts/clean.sh deleted file mode 100644 index 619853e2fb..0000000000 --- a/frontend/scripts/clean.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -#!/usr/bin/env fish - -cd rust-lib -cargo clean - -cd ../../shared-lib -cargo clean - -CACHE_FILE=lib-infra/.cache -if [ -d "$CACHE_FILE" ]; then - echo "Remove $CACHE_FILE" - rm -rf $CACHE_FILE -fi - - diff --git a/frontend/scripts/makefile/tool.toml b/frontend/scripts/makefile/tool.toml index fcd1d41763..85dc76cb8b 100644 --- a/frontend/scripts/makefile/tool.toml +++ b/frontend/scripts/makefile/tool.toml @@ -1,29 +1,35 @@ [tasks.rust_clean] +run_task = { name = ["cargo_clean","rm_macro_build_cache", "rm_generated_protobuf_files"] } + +[tasks.cargo_clean] script = [ """ cd rust-lib - cargo clean + cargo clean -q cd ../../shared-lib - cargo clean - - CACHE_FILE=lib-infra/.cache - if [ -d "$CACHE_FILE" ]; then - echo "Remove $CACHE_FILE" - rm -rf $CACHE_FILE - fi + cargo clean -q """, ] script_runner = "@shell" -[tasks.rust_clean.windows] + +[tasks.rm_macro_build_cache] +script = [ + """ + path = canonicalize ../shared-lib/lib-infra/.cache + if is_path_exists ${path} + rm -rf ${path} + end + """, +] +script_runner = "@duckscript" + + +[tasks.rm_generated_protobuf_files] script = [ """ - cd rust-lib - cargo clean - cd ../../shared-lib - rmdir /s/q "lib-infra/.cache" """, ] script_runner = "@duckscript" \ No newline at end of file