Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 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(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 @@ -45,9 +51,11 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta

let run = obj['run']
if (isArray(run)) {
run = run.join("\n")
run = run.map(x => mm.apply(x, tokens)).join("\n")
} else if (!isString(run)) {
throw new Error('every node in a script YAML array must contain a `run` key')
} else {
run = mm.apply(run, tokens)
}

let cd = obj['working-directory']
Expand Down Expand Up @@ -90,10 +98,9 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta

return run.trim()
} else {
return `${obj}`.trim()
return mm.apply(`${obj}`, tokens).trim()
}
}).join("\n\n")
return mm.apply(validate.str(input), tokens)
}

if (isPlainObject(node)) {
Expand Down
11 changes: 11 additions & 0 deletions projects/stark.com/foo/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ build:

# check for regression
- test $PREFIX = {{prefix}}

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

# test run scripts tokenize at the start
- run: ${{prefix}}/bin/stark

# test you can array off a run:
- run:
- ${{prefix}}/bin/stark
- ${{prefix}}/bin/stark
env:
PREFIX: ${{prefix}}

Expand Down