Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugojosefson/deno-run-simple
Simple `run` function to execute shell commands in Deno.
https://github.com/hugojosefson/deno-run-simple
bash command deno exec process run sh shell simple spawn
Last synced: about 2 months ago
JSON representation
Simple `run` function to execute shell commands in Deno.
- Host: GitHub
- URL: https://github.com/hugojosefson/deno-run-simple
- Owner: hugojosefson
- License: mit
- Created: 2022-07-15T11:58:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-30T22:51:38.000Z (2 months ago)
- Last Synced: 2024-11-30T23:22:46.824Z (2 months ago)
- Topics: bash, command, deno, exec, process, run, sh, shell, simple, spawn
- Language: TypeScript
- Homepage: https://jsr.io/@hugojosefson/run-simple
- Size: 90.8 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @hugojosefson/run-simple
Simple `run` function to execute shell commands in Deno.
Returns a Promise of what the command printed. Rejects with status if the
command fails.[![JSR Version](https://jsr.io/badges/@hugojosefson/run-simple)](https://jsr.io/@hugojosefson/run-simple)
[![JSR Score](https://jsr.io/badges/@hugojosefson/run-simple/score)](https://jsr.io/@hugojosefson/run-simple)
[![CI](https://github.com/hugojosefson/deno-run-simple/actions/workflows/release.yaml/badge.svg)](https://github.com/hugojosefson/deno-run-simple/actions/workflows/release.yaml)## Requirements
Requires [Deno](https://deno.com/) v1.46.3 or later. Version 2+ is recommended.
## API
Please see docs on
[jsr.io/@hugojosefson/run-simple](https://jsr.io/@hugojosefson/run-simple).## Installation
```sh
# add as dependency to your project
deno add jsr:@hugojosefson/run-simple
```## Example usage
```typescript
// example-usage.tsimport { run } from "@hugojosefson/run-simple";
// Simple command
const dir: string = await run("ls -l");
console.log(dir);// Command with variable argument
const uid = 1000;
const idLine: string = await run(["id", uid]);
console.log(idLine);// An argument contains spaces
const remoteHost = "10.20.30.40";
const remoteCommand = "ps -ef --forest";
const remoteProcessTree: string = await run(["ssh", remoteHost, remoteCommand]);
console.log(remoteProcessTree);// Supply STDIN to the command
const contents = `# Remote fileThis will be the contents of the remote file.
`;
await run(
["ssh", remoteHost, "bash", "-c", "cat > remote_file.md"],
{ stdin: contents },
);
```You may run the above example with:
```sh
deno run --allow-run ./example-usage.ts
```Or directly from here:
```sh
deno run --allow-run --reload jsr:@hugojosefson/run-simple/example-usage
```