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
6 changes: 6 additions & 0 deletions docs/Ake.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ ake greetings # finds ../ake and runs it in the project directory

The working directory is automatically set to the project directory (where the ake file lives), so `$` commands always run relative to the project root.

## Global Variables

```ts
PROJECT_DIR // absolute path to the project dir
```

## Multiple Ake Files

Any file named `ake<suffix>` or `ake<suffix>.ts` is supported.
Expand Down
5 changes: 3 additions & 2 deletions docs/Global Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ $`cat ${files}` // cat a.txt b.txt
## Global Variables

```ts
app // Command instance for defining CLI metadata and commands
$ // Shell command tagged template
app // Command instance for defining CLI metadata and commands
$ // Shell command tagged template
PROJECT_DIR // ake only: absolute path to the project dir (where the ake file lives)
```
1 change: 1 addition & 0 deletions src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
}
const projectDir = getProjectDir(scriptPath)
process.chdir(projectDir)
;(globalThis as any).PROJECT_DIR = projectDir
}

async parse(argv: string[]): Promise<void> {
Expand Down Expand Up @@ -425,7 +426,7 @@
})
}
if (c.commands.length > 0) {
const childPrefix = prefix ? `${prefix} ${c._name}` : c._name!

Check warning on line 429 in src/Command.ts

View workflow job for this annotation

GitHub Actions / lint

lint/style/noNonNullAssertion

Forbidden non-null assertion.
result.push(...c.#collectCommands(childPrefix))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import type { $ as Shell } from './spawn'
declare global {
var app: Command
var $: typeof Shell
var PROJECT_DIR: string
}
Loading