From e9fc42892f7d622b96de212ae7d57569090bc811 Mon Sep 17 00:00:00 2001 From: mono Date: Sat, 1 Jun 2024 23:36:45 +0900 Subject: [PATCH] Make install.ts standalone script --- install.ps1 | 18 +++--------------- install.sh | 12 +++--------- install/main.ts => install.ts | 6 +++--- 3 files changed, 9 insertions(+), 27 deletions(-) rename install/main.ts => install.ts (96%) diff --git a/install.ps1 b/install.ps1 index df06207..b60706c 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,12 +1,5 @@ $ErrorActionPreference = "Stop" -# https://stackoverflow.com/questions/34559553/create-a-temporary-directory-in-powershell -function New-TemporaryDirectory { - $parent = [System.IO.Path]::GetTempPath() - $name = [System.IO.Path]::GetRandomFileName() - New-Item -ItemType Directory -Path (Join-Path $parent $name) -} - $deno = "deno" if (-not (Get-Command deno -ErrorAction SilentlyContinue)) { $env:DENO_INSTALL = "$env:USERPROFILE\.local" @@ -16,13 +9,8 @@ if (-not (Get-Command deno -ErrorAction SilentlyContinue)) { $prefix = Split-Path -Parent $PSCommandPath -if (-not (Test-Path "$prefix\install\main.ts")) { - $dir = New-TemporaryDirectory - New-Item -ItemType Directory -Force -Path "$dir\install" - foreach ($file in "install/main.ts", "deno.jsonc", "deno.lock") { - Invoke-WebRequest -Uri "https://raw.githubusercontent.com/mono0x/dotfiles/main/$file" -OutFile "$dir\$file" - } - $prefix = $dir +if (-not (Test-Path "$prefix\install.ts")) { + $prefix = "https://raw.githubusercontent.com/mono0x/dotfiles/main/" } -. "$deno" run -A --config "$prefix/deno.jsonc" --lock "$prefix/deno.lock" "$prefix/install/main.ts" +. "$deno" run -A "$prefix/install.ts" diff --git a/install.sh b/install.sh index 4aaf0b5..52a6c89 100755 --- a/install.sh +++ b/install.sh @@ -12,15 +12,9 @@ else fi prefix="$(dirname "$0")" -if [ ! -f "$prefix/install/main.ts" ] +if [ ! -f "$prefix/install.ts" ] then - dir="$(mktemp --tmpdir -d dotfiles.XXXXXX)" - mkdir -p "$dir/install" - for file in install/main.ts deno.jsonc deno.lock - do - curl -fsSL "https://raw.githubusercontent.com/mono0x/dotfiles/main/$file" -o "$dir/$file" - done - prefix="$dir" + prefix="https://raw.githubusercontent.com/mono0x/dotfiles/main/" fi -exec "$deno" run --config "$prefix/deno.jsonc" --lock "$prefix/deno.lock" -A "$prefix/install/main.ts" +exec "$deno" run -A "$prefix/install.ts" diff --git a/install/main.ts b/install.ts similarity index 96% rename from install/main.ts rename to install.ts index a573391..906a212 100644 --- a/install/main.ts +++ b/install.ts @@ -1,6 +1,6 @@ -import $ from "@david/dax"; -import * as fs from "@std/fs"; -import * as path from "@std/path"; +import $ from "jsr:@david/dax@^0.41.0"; +import * as fs from "jsr:@std/fs@^0.221.0"; +import * as path from "jsr:@std/path@^0.221.0"; $.setPrintCommand(true);