Skip to content

Commit 1098716

Browse files
committed
Have command not found handler sync
Sync is quick if they have done it recently. Let’s see how this feels. Rationale: We add new pkgs all the time.
1 parent 13d8128 commit 1098716

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ type Args = BaseArgs & { flags: { verbosity: number } }
2828

2929
export default async function({ flags, ...opts }: Args, logger_prefix?: string) {
3030
if (flags.sync) {
31-
await useSync() //TODO Logger
31+
try {
32+
await useSync() //TODO Logger
33+
} catch (err) {
34+
if (!flags.keepGoing) throw err
35+
}
3236
}
3337

3438
const logger = make_logger(flags.verbosity, logger_prefix)

src/modes/shellcode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default function() {
102102
if [ "$1" = pkgx ]; then
103103
echo 'fatal: \`pkgx\` not in PATH' >&2
104104
return 1
105-
elif command pkgx --silent --provider "$1"; then
105+
elif command pkgx --sync --keep-going --silent --provider "$1"; then
106106
echo -e '${dim('^^ type `')}x${dim('` to run that')}' >&2
107107
108108
d="${tmp}/shellcode"

src/parse-args.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ interface Flags {
4545
sync: boolean
4646
update: boolean
4747
verbosity?: number
48+
keepGoing: boolean
4849
}
4950

5051
export default function(input: string[]): Args {
@@ -54,7 +55,8 @@ export default function(input: string[]): Args {
5455
const unknown: string[] = []
5556
const flags: Flags = {
5657
sync: false,
57-
update: false
58+
update: false,
59+
keepGoing: false
5860
}
5961
let mode: string | undefined
6062
let dryrun: boolean | undefined
@@ -111,6 +113,9 @@ export default function(input: string[]): Args {
111113
case 'dry-run':
112114
dryrun = true
113115
break
116+
case 'keep-going':
117+
flags.keepGoing = true
118+
break
114119
case '':
115120
// empty the main loop iterator
116121
for (const arg of it) unknown.push(arg)

0 commit comments

Comments
 (0)