denoland / denoland/deno_task_shell

Support ?= short hand for setting variable if not already set

Open
#69 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
139
Forks
25
PR merge metrics
No merged PRs in 30d

Description

https://www.gnu.org/software/make/manual/html_node/Setting.html#Setting

This would make it easier to re-use deno tasks in other tasks that have different environment variables.

```json
{
"tasks": {
"run": "export APP_ENV ?= production && deno run --allow-read=. --allow-write=. scripts/run.js",
"run-dev": "export APP_ENV = development && deno task run"
},
}
```

Currently that short hand won't work and will give you the following error.

```
$ deno task run
Task run export APP_ENV ?= production && deno run --allow-read=. --allow-write=. scripts/run.js
error: Error parsing script 'run'.

Caused by:
Globs are currently not supported, but will be soon.
?= production && deno run --allow-read=. --allow-write=. scripts/run.js
~
```

Since the shorthand doesn't work currently, you have to either repeat or move the common part to a separate task. The downside to the second shorthand example below is that people might use run without APP_ENV set.

```json
{
"tasks": {
"run": "export APP_ENV = production && deno run --allow-read=. --allow-write=. scripts/run.js",
"run-dev": "export APP_ENV = development && deno run --allow-read=. --allow-write=. scripts/run.js"
},
}
```

```json
{
"tasks": {
"run": "deno run --allow-read=. --allow-write=. scripts/run.js",
"run-prod": "export APP_ENV = production && deno task run"
"run-dev": "export APP_ENV = development && deno task run"
},
}
```

I was told by @bartlomieju to ping @dsherret on this feature request.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.