forked from pkgxdev/pkgx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow symlinks to tea to execute those commands (pkgxdev#191)
- Loading branch information
1 parent
d0de85c
commit a8c499d
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { isNumber } from "is_what" | |
import { set_tmp } from "path" | ||
import { usePrefix } from "hooks" | ||
import Path from "path" | ||
import { lstatSync } from "https://deno.land/[email protected]/node/fs.ts"; | ||
|
||
// doing here as this is the only file all our scripts import | ||
set_tmp(usePrefix().join('tea.xyz/tmp')) | ||
|
@@ -63,10 +64,18 @@ export type Args = { | |
export function useArgs(args: string[], arg0: string): [Args, Flags & ConvenienceFlags] { | ||
if (flags) throw new Error("contract-violated") | ||
|
||
if (/(.+\/|^)tea_(.+)$/.test(arg0)) { | ||
args = [...args] // args is usually the immutable `Deno.args` | ||
const match = arg0.match(/tea_(.+)$/)! | ||
args.unshift("-X", match[1]) | ||
if (lstatSync(arg0).isSymbolicLink()) { | ||
const arg0_basename = new Path(arg0).basename() | ||
if (arg0_basename != "tea") { | ||
args = [...args] // args is usually the immutable `Deno.args` | ||
if (/^tea_([^\/]+)$/.test(arg0_basename)) { | ||
//TODO apply non-magic mode | ||
const match = arg0_basename.match(/^tea_([^\/]+)$/)! | ||
args.unshift("-X", match[1]) | ||
} else { | ||
args.unshift("-X", arg0_basename) | ||
} | ||
} | ||
} | ||
|
||
const rv: Args = { | ||
|