@jpillora/take 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/take.d.mts +2 -0
- package/take.mjs +10 -1
package/package.json
CHANGED
package/take.d.mts
CHANGED
|
@@ -20,6 +20,7 @@ export declare function newFlags<F extends Flags>(flags: F): F;
|
|
|
20
20
|
export type NewCommand<F extends Flags = Flags> = TakeCommand<F> & {
|
|
21
21
|
flagValues: FlagValues<F>;
|
|
22
22
|
input: CommandInput<F>;
|
|
23
|
+
flagsInitial: FlagValues<F>;
|
|
23
24
|
};
|
|
24
25
|
export type CommandInput<F extends Flags> = {
|
|
25
26
|
flags: FlagValues<F>;
|
|
@@ -34,6 +35,7 @@ export type SpawnOptions = {
|
|
|
34
35
|
args?: string[];
|
|
35
36
|
} & nodeSpawnOptions;
|
|
36
37
|
export declare function spawn(options: SpawnOptions): Promise<number>;
|
|
38
|
+
export declare const $: (script: string) => Promise<void>;
|
|
37
39
|
export declare const timer: () => () => string;
|
|
38
40
|
export declare function Register(...commands: NewCommand<any>[]): Promise<void>;
|
|
39
41
|
export declare function Command<F extends Flags>(command: TakeCommand<F>): NewCommand<F>;
|
package/take.mjs
CHANGED
|
@@ -51,6 +51,14 @@ export async function spawn(options) {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
// helper for running bash scripts
|
|
55
|
+
export const $ = async (script) => {
|
|
56
|
+
await spawn({
|
|
57
|
+
program: "bash",
|
|
58
|
+
args: ["-c", script],
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
});
|
|
61
|
+
};
|
|
54
62
|
// helper for measuring time
|
|
55
63
|
export const timer = (() => {
|
|
56
64
|
const scale = [
|
|
@@ -364,7 +372,8 @@ export async function Register(...commands) {
|
|
|
364
372
|
}
|
|
365
373
|
}
|
|
366
374
|
export function Command(command) {
|
|
367
|
-
|
|
375
|
+
const flagsInitial = Object.fromEntries(Object.entries(command.flags).map(([k, v]) => [k, v.initial]));
|
|
376
|
+
return { ...command, flagValues: null, input: null, flagsInitial };
|
|
368
377
|
}
|
|
369
378
|
// deno-lint-ignore no-constant-condition
|
|
370
379
|
if (42 < 7) {
|