-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(runtime): don't inject globals by default (#72)
- Loading branch information
Showing
10 changed files
with
74 additions
and
90 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference path="./types.d.ts" /> | ||
|
||
import { initGlobals } from "./src/runtime/globals.ts"; | ||
|
||
initGlobals(); |
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as globals from "./mod.ts"; | ||
|
||
export function initGlobals() { | ||
Object.assign(self, globals); | ||
} |
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 |
---|---|---|
@@ -1,78 +1,6 @@ | ||
/// <reference path="../../types.d.ts" /> | ||
|
||
import { | ||
async, | ||
colors, | ||
flags, | ||
fs, | ||
io, | ||
log, | ||
path, | ||
shq, | ||
streams, | ||
} from "./deps.ts"; | ||
import { cd } from "./cd.ts"; | ||
import { exec, statusOnly, stderrOnly, stdoutOnly } from "./exec.ts"; | ||
import { quote } from "./quote.ts"; | ||
|
||
export { async, flags, fs, io, log, path, streams } from "./deps.ts"; | ||
export { $, $e, $o, $s } from "./shell.ts"; | ||
export { cd } from "./cd.ts"; | ||
export { quote } from "./quote.ts"; | ||
export { ProcessError } from "./process_error.ts"; | ||
export { ProcessOutput } from "./process_output.ts"; | ||
|
||
export type $ = typeof exec & typeof colors & { | ||
get mainModule(): string; | ||
get args(): Array<string>; | ||
get verbose(): number; | ||
set verbose(value: boolean | number); | ||
get startTime(): number; | ||
shell: string; | ||
prefix: string; | ||
stdout: NonNullable<Deno.RunOptions["stdout"]>; | ||
stderr: NonNullable<Deno.RunOptions["stderr"]>; | ||
quote: typeof shq; | ||
throwErrors: boolean; | ||
time: number; | ||
}; | ||
|
||
export const $: $ = exec as $; | ||
export const $s: typeof statusOnly = statusOnly; | ||
export const $o: typeof stdoutOnly = stdoutOnly; | ||
export const $e: typeof stderrOnly = stderrOnly; | ||
|
||
Object.setPrototypeOf($, Object.getPrototypeOf(colors)); | ||
|
||
$._stack = []; | ||
$.shell = "/bin/bash"; | ||
$.prefix = "set -euo pipefail;"; | ||
$.stdout = "piped"; | ||
$.stderr = "piped"; | ||
$.quote = shq; | ||
$.throwErrors = false; | ||
|
||
let _verbose = 1; | ||
Object.defineProperty($, "verbose", { | ||
get: (): number => _verbose, | ||
set: (verbose: boolean | number) => _verbose = Number(verbose), | ||
}); | ||
|
||
Object.defineProperty($, "time", { | ||
get: () => Date.now() - $.startTime, | ||
}); | ||
|
||
// dzx | ||
self.$ = $; | ||
self.$s = $s; | ||
self.$o = $o; | ||
self.$e = $e; | ||
self.cd = cd; | ||
self.quote = quote; | ||
|
||
// x | ||
self.async = async; | ||
self.path = path; | ||
self.io = io; | ||
self.streams = streams; | ||
self.fs = fs; | ||
self.log = log; | ||
self.flags = flags; | ||
|
||
export { async, cd, flags, fs, io, log, path, quote, streams }; |
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
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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { colors, shq } from "./deps.ts"; | ||
import { exec, statusOnly, stderrOnly, stdoutOnly } from "./exec.ts"; | ||
|
||
export type $ = typeof exec & typeof colors & { | ||
get mainModule(): string; | ||
get args(): Array<string>; | ||
get verbose(): number; | ||
set verbose(value: boolean | number); | ||
get startTime(): number; | ||
shell: string; | ||
prefix: string; | ||
stdin: NonNullable<Deno.RunOptions["stdin"]>; | ||
stdout: NonNullable<Deno.RunOptions["stdout"]>; | ||
stderr: NonNullable<Deno.RunOptions["stderr"]>; | ||
quote: typeof shq; | ||
throwErrors: boolean; | ||
time: number; | ||
}; | ||
|
||
export const $: $ = exec as $; | ||
export const $s: typeof statusOnly = statusOnly; | ||
export const $o: typeof stdoutOnly = stdoutOnly; | ||
export const $e: typeof stderrOnly = stderrOnly; | ||
|
||
Object.setPrototypeOf($, Object.getPrototypeOf(colors)); | ||
|
||
$._stack = []; | ||
$.shell = "/bin/bash"; | ||
$.prefix = "set -euo pipefail;"; | ||
$.stdin = "inherit"; | ||
$.stdout = "piped"; | ||
$.stderr = "piped"; | ||
$.quote = shq; | ||
$.throwErrors = false; | ||
|
||
let _verbose = 1; | ||
Object.defineProperty($, "verbose", { | ||
get: (): number => _verbose, | ||
set: (verbose: boolean | number) => _verbose = Number(verbose), | ||
}); | ||
|
||
Object.defineProperty($, "time", { | ||
get: () => Date.now() - $.startTime, | ||
}); |