Skip to content

Commit

Permalink
fix make file and shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
jwson-automation committed Aug 12, 2024
1 parent 0c7d471 commit c368a9d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ else
@$(FLUTTER) pub run build_runner build --delete-conflicting-outputs
endif

# .env 파일 생성 명령
# Define the env target for Unix-like systems
env:
@bash generate_env.sh
ifeq ($(DETECTED_OS), Windows)
@echo "Using PowerShell script to create .env file."
@powershell -ExecutionPolicy Bypass -File generate_env.ps1 $/lib
else
@echo "Using bash script to create .env file."
@bash generate_env.sh $/lib
endif
28 changes: 28 additions & 0 deletions generate_env.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# PowerShell 스크립트로 .env 파일 생성

param (
[string]$TargetDir
)

# 디버깅 출력
Write-Output "Target Directory: $TargetDir"

# 빈 문자열이 전달되었는지 확인
if ([string]::IsNullOrWhiteSpace($TargetDir)) {
Write-Error "Target directory is not specified or is empty."
exit 1
}

# .env 파일 내용
$envContent = @"
# please replace 'your_api_key_here' with your actual API key
API_KEY=your_api_key_here
# Other environment variables can be added here
"@

# .env 파일 생성
$envFilePath = Join-Path -Path $TargetDir -ChildPath ".env"
Write-Output "Creating .env file at: $envFilePath"

# UTF-8 인코딩으로 파일 생성
$envContent | Out-File -FilePath $envFilePath -Encoding utf8
12 changes: 6 additions & 6 deletions generate_env.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

# .env 파일 생성
echo "# API 키를 추가해주세요." >> .env
echo "API_KEY=your_api_key_here" >> .env
echo "# Other environment variables can be added here" >> .env
# .env 파일 생성 경로
TARGET_DIR=$1

# 파일 생성 후 권한 변경 (선택 사항)
chmod 600 .env
# .env 파일 생성
echo "# API 키를 추가해주세요." > "$TARGET_DIR/.env"
echo "API_KEY=your_api_key_here" >> "$TARGET_DIR/.env"
echo "# Other environment variables can be added here" >> "$TARGET_DIR/.env"

0 comments on commit c368a9d

Please sign in to comment.