From 36b956e5b47e2ca4e077f021fc3b76f9be96d8dd Mon Sep 17 00:00:00 2001 From: Nejc Drobnic <7919610+QuantumlyTangled@users.noreply.github.com> Date: Fri, 24 Jul 2020 19:26:24 +0200 Subject: [PATCH] feat(scripts): pwsh script for manipulating the yarn cache (#1134) --- .editorconfig | 7 ++++++- scripts/dependencycache.ps1 | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 scripts/dependencycache.ps1 diff --git a/.editorconfig b/.editorconfig index a399bcdd380..145d6185bc5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,7 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true -[*.{js,ts}] +[*.{js,ts,mjs}] indent_size = 4 indent_style = tab block_comment_start = /* @@ -20,3 +20,8 @@ indent_style = space [*.{md,rmd,mkd,mkdn,mdwn,mdown,markdown,litcoffee}] tab_width = 4 trim_trailing_whitespace = false + +[*.{ps1}] +max_line_length = 115 +indent_size = 4 +indent_style = space diff --git a/scripts/dependencycache.ps1 b/scripts/dependencycache.ps1 new file mode 100644 index 00000000000..4be0bf9c56f --- /dev/null +++ b/scripts/dependencycache.ps1 @@ -0,0 +1,26 @@ +Function Step-Main { + Param ( + [string]$Command = "default", + [string]$Manager = "yarn" + ) + + Process { + switch ( $Command ) { + clear { + Remove-Item -Recurse -Force -ErrorAction Ignore dist + Remove-Item -Recurse -Force -ErrorAction Ignore node_modules + switch ($Manager) { + yarn { + Remove-Item -Recurse -Force -ErrorAction Ignore $(yarn cache dir) + } + npm { + npm cache rm --force + } + } + } + default { Write-Host "Unrecognized command, please try again" -ForegroundColor Red } + } + } +} + +Step-Main @args