1- # testplay/test.ps1
2- # mock/ をコピーして run/ に対して indentier + このプラグインを実行するテストスクリプト
3- #
4- # 使い方:
5- # .\testplay\test.ps1 # default モード、全ファイルを表示
6- # .\testplay\test.ps1 --mode=ruby # ruby モード
7- # .\testplay\test.ps1 --show sample.rs # 特定ファイルの結果のみ表示
8- #
9- # --show <file> は複数指定可。省略時は全ファイルを表示。
10- # それ以外の引数はすべて indentier にそのまま渡される。
11- #
12- # 前提: このパッケージと indentier/ 両方で pnpm build を実行しておくこと。
13-
141$PackageDir = Split-Path $PSScriptRoot - Parent
152$IndentierDir = Join-Path (Split-Path $PackageDir - Parent) " indentier"
163$MockDir = Join-Path $PSScriptRoot " mock"
@@ -31,17 +18,14 @@ while ($i -lt $args.Count) {
3118 $i ++
3219}
3320
34- # --- run/ をリフレッシュ ---
3521if (Test-Path $RunDir ) { Remove-Item $RunDir - Recurse - Force }
3622Copy-Item $MockDir $RunDir - Recurse
3723Write-Host " Copied mock/ -> run/" - ForegroundColor Cyan
3824
39- # --- プラグイン設定を run/ に配置 (indentier/dist/ 起点の相対パス、BOM なし UTF-8) ---
4025$pluginName = Split-Path $PackageDir - Leaf
4126$configPath = Join-Path $RunDir " .indentierrc.json"
4227[System.IO.File ]::WriteAllText($configPath , " {`" plugins`" :[`" ../../$pluginName /dist/index.mjs`" ]}" , [System.Text.UTF8Encoding ]::new($false ))
4328
44- # --- indentier 実行 2回 (idempotency 確認) ---
4529$cmdArgs = @ (" $Cli " , ' --write' , ' .' ) + $IndentierArgs
4630foreach ($n in 1 , 2 ) {
4731 Write-Host " Running ($n /2): node $ ( $cmdArgs -join ' ' ) (cwd: $RunDir )" - ForegroundColor Cyan
@@ -50,7 +34,6 @@ foreach ($n in 1, 2) {
5034 Pop-Location
5135}
5236
53- # --- 結果表示 ---
5437$filesToShow = if ($Show.Count -gt 0 ) {
5538 $Show | ForEach-Object { Join-Path $RunDir $_ }
5639} else {
@@ -65,4 +48,4 @@ foreach ($f in $filesToShow) {
6548 } else {
6649 Write-Host " Not found: $f " - ForegroundColor Red
6750 }
68- }
51+ }
0 commit comments