Skip to content

Commit

Permalink
Fixes #141; Cannot start array script lines with $
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Dec 13, 2023
1 parent 3ed2f9e commit 40085d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/hooks/usePantry.getScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta
}

const script = (input: unknown) => {
if (isArray(input)) input = input.map(obj => {
if (isString(input)) {
return mm.apply(validate.str(input), tokens)
} else if (!isArray(input)) {
throw new Error("script node is not string or array")
}

return input.map(obj => {
if (isPlainObject(obj)) {

const condition = obj["if"]
Expand All @@ -50,6 +56,8 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta
throw new Error('every node in a script YAML array must contain a `run` key')
}

run = mm.apply(validate.str(input), tokens)

let cd = obj['working-directory']
if (cd) {
cd = mm.apply(validate.str(cd), tokens)
Expand Down Expand Up @@ -93,7 +101,6 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta
return `${obj}`.trim()
}
}).join("\n\n")
return mm.apply(validate.str(input), tokens)
}

if (isPlainObject(node)) {
Expand Down
3 changes: 3 additions & 0 deletions projects/stark.com/foo/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ build:
# check for regression
- test $PREFIX = {{prefix}}

# tests we support script lines starting with $
- ${{prefix}}/bin/stark
env:
PREFIX: ${{prefix}}

Expand Down

0 comments on commit 40085d9

Please sign in to comment.