Skip to content

Commit

Permalink
Add shortcut for shell().exec
Browse files Browse the repository at this point in the history
  • Loading branch information
tobeno committed Jul 16, 2023
1 parent 304963c commit 8c7c353
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/mutations/global.mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import { Directory } from '../wrappers/directory.wrapper';
import { File } from '../wrappers/file.wrapper';
import { Html } from '../wrappers/html.wrapper';
import { Markdown } from '../wrappers/markdown.wrapper';
import { Shell } from '../wrappers/shell.wrapper';
import { Text } from '../wrappers/text.wrapper';
import { TmpDirectory } from '../wrappers/tmp-directory.wrapper';
import { TmpFile } from '../wrappers/tmp-file.wrapper';
import { Url } from '../wrappers/url.wrapper';
import { Xml } from '../wrappers/xml.wrapper';
import { Shell } from '../wrappers/shell.wrapper';

export const globals = {
args: withHelp(
Expand Down Expand Up @@ -115,6 +115,18 @@ export const globals = {
},
'Returns the environment variables',
),
exec: withHelp(
{
get() {
const { Shell } =
require('../wrappers/shell.wrapper') as typeof import('../wrappers/shell.wrapper');
const shell = Shell.create();

return shell.exec.bind(shell);
},
},
'Executes the given command',
),
fake: withHelp(
{
get() {
Expand Down Expand Up @@ -375,6 +387,7 @@ declare global {
const dir: Globals['dir'];
const dirs: Globals['dirs'];
const env: Globals['env'];
const exec: Globals['exec'];
const file: Globals['file'];
const files: Globals['files'];
const fileCached: Globals['fileCached'];
Expand Down

0 comments on commit 8c7c353

Please sign in to comment.