# var-sub

> Bash style variable substitutions.

Latest version **1.1.0** (published 2020-03-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install var-sub
pnpm add var-sub
yarn add var-sub
bun add var-sub
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-03-02 |
| First published | 2020-02-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Joe Flateau |
| Maintainers | joeflateau |
| Keywords | bash, string, substitution, variables, interpolation |

## Links

- npm: https://www.npmjs.com/package/var-sub
- npm.io page: https://npm.io/package/var-sub

## Dependencies (2)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2020-03-02
- 1.0.6 — 2020-03-01
- 1.0.5 — 2020-02-29
- 1.0.4 — 2020-02-29
- 1.0.3 — 2020-02-29
- 1.0.2 — 2020-02-29
- 1.0.1 — 2020-02-29
- 1.0.0 — 2020-02-29

## README

# var-sub

Bash style variable substitutions.

## String replacements

```typescript
await stringFromTemplate(`foo $BAR`, {
  BAR: "baz"
}); // foo baz

await stringFromTemplate("foo ${bar}", {
  BAR: "baz"
}); // foo baz

await stringFromTemplate("my home dir is $HOME", {
  ...process.env
}); // my home dir is /Users/joeflateau

await stringFromTemplate(
  await request.get("https://example.org/some/template"),
  {
    FOO: "bar"
  }
);
```

## File replacements

```typescript
await stringFromTemplateFile(__dirname + "/cloudfront.template.json", {
  VIEWER_REQUEST_FUNCTION_ARN: viewerRequestFunctionArn,
  ORIGIN_RESPONSE_FUNCTION_ARN: originResponseFunctionArn,
  CALLER_REFERENCE: callerReference,
  STAGE,
  CNAME
});
```

## Recursive copy w/ replacements

```typescript
await copyFromTemplateFiles(
  __dirname + "/../srcDir",
  "./**/*.txt",
  __dirname + "/../destDir",
  { BAR: "bar" }
);
```

---
_Source: https://npm.io/package/var-sub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
