Skip to content

Commit

Permalink
fix pluralization of img outdir
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi committed Mar 25, 2024
1 parent bf05b75 commit ea7fce7
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/create-image-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
required: true
type: string
image:
description: 'Image Type (banner, meetup)'
description: 'Image Type (banner, meetup-image)'
default: banner
type: string

Expand Down Expand Up @@ -38,18 +38,12 @@ jobs:
npm i tsx -g
cd ./packages/image-generator
npm i
cd ../..
IFS=',' read -ra ADDR <<< "${{ inputs.image }}"
for i in "${ADDR[@]}"; do
trimmed=$(echo "$i" | xargs) # Trim whitespace
# Create directory if it doesn't exist
echo "$trimmed"
mkdir -p "./public/${trimmed}"
tsx --tsconfig ./packages/image-generator/tsconfig.json ./packages/image-generator/cli.ts --image "${trimmed}" --date ${{ inputs.date }} > "./public/${trimmed}/${{ inputs.date }}.png"
mkdir -p "../../public/${trimmed}s"
npm run --silent cli -- --image "${trimmed}" --date ${{ inputs.date }} > "../../public/${trimmed}s/${{ inputs.date }}.png"
done
- name: Generate unique branch name
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
description: 'Event Date (YYYY-MM-DD)'
required: true
image:
description: 'Image Type (banner, meetup)'
description: 'Image Type (banner, meetup-image)'
default: banner
type: string

Expand Down
8 changes: 6 additions & 2 deletions packages/image-generator/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import {buildRelative} from './index'

const program = new Command()

program.option('-i, --image <string>', 'Image path').option('-d, --date <string>', 'Date string')
program
.option('-i, --image <string>', 'Image path')
.option('-d, --date <string>', 'Date string')
.option('-o, --out <string>', 'Output Path string')

program.parse(process.argv)

const options = program.opts()

const image = options.image && typeof options.image === 'string' ? options.image : null
const date = options.date && typeof options.date === 'string' ? options.date : null
const outputPath = options.out && typeof options.out === 'string' ? options.out : null

if (image && date) {
buildRelative({image, date})
buildRelative({image, date, outputPath})
} else {
console.error('Both image and date flags are required.')
process.exit(1)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/image-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"cli": "tsx --tsconfig ./tsconfig.json ./cli.ts"
},
"keywords": [],
"author": "",
Expand Down

0 comments on commit ea7fce7

Please sign in to comment.