Skip to content

Commit

Permalink
Merge 3fbb7c5 into 104affb
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Feb 22, 2024
2 parents 104affb + 3fbb7c5 commit 3881796
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 529 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
with:
deno-version: 1.39
deno-version: '1.41'
- run: deno cache **/*.test.ts
- run: deno task test --coverage=cov_profile --no-check
- run: deno coverage cov_profile --lcov --exclude=tests/ --output=cov_profile.lcov
Expand All @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
with:
deno-version: 1.39
deno-version: '1.41'
- run: deno lint

typecheck:
Expand All @@ -68,5 +68,5 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: 1.39
deno-version: '1.41'
- run: deno task typecheck
10 changes: 5 additions & 5 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
},
"tasks": {
// runs this source checkout, args will be passed
"run": "deno run --unstable -A ./entrypoint.ts",
"run": "deno run --unstable-fs --unstable-ffi -A ./entrypoint.ts",

// you can specify paths to specific tests if you need
// follows is the ideal permissions lines, unfortunately deno considers making symlinks to require full read/write permissions for fuck knows why reasons
//"test": "deno test --allow-read=$PWD,$TMPDIR,$HOME,/ --allow-env --allow-write=$TMPDIR --allow-ffi --unstable",
"test": "deno test --allow-read --allow-env --allow-write --allow-ffi --unstable",
"test": "deno test --unstable-ffi --allow-ffi --allow-read --allow-env --allow-write",
// ^^ ffi & unstable needed for execve.ts

// installs to /usr/local/bin/pkgx
"install": "deno task compile && ./pkgx +gnu.org/coreutils /usr/bin/sudo install -D ./pkgx /usr/local/bin/pkgx",

//--------------------------------------- ci/cd/admin
"coverage" : "scripts/run-coverage.sh",
"typecheck": "deno check --unstable ./entrypoint.ts",
"compile": "deno compile --lock=deno.lock --allow-read --allow-write --allow-net --allow-run --allow-env --allow-ffi --unstable --output $INIT_CWD/pkgx ./entrypoint.ts"
"typecheck": "deno check ./entrypoint.ts",
"compile": "deno compile --lock=deno.lock --allow-read --allow-write --allow-net --allow-run --allow-env --allow-ffi --unstable-ffi --unstable-fs --output $INIT_CWD/pkgx ./entrypoint.ts"
},
"pkgx": "deno~1.39",
"pkgx": "deno~1.41.0",
"lint": {
"exclude": ["src/**/*.test.ts"]
},
Expand Down
551 changes: 39 additions & 512 deletions deno.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { render as perror } from "./src/err-handler.ts"
import { setColorEnabled } from "deno/fmt/colors.ts"
import clicolor from "./src/utils/clicolor.ts"

setColorEnabled(clicolor(Deno.stderr.rid))
setColorEnabled(clicolor(Deno.stderr))

///////////////////////////////////////////////////////// backwards compatability
const argstr = Deno.args.join(' ')
Expand Down Expand Up @@ -71,7 +71,7 @@ try {

/////////////////////////////////////////////////////////////////////////// utils
function logger_prefix() {
if (Deno.env.get("CI") || !Deno.isatty(Deno.stdin.rid)) {
if (Deno.env.get("CI") || !Deno.stdin.isTerminal()) {
return 'pkgx'
}
}
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default async function({ flags, ...opts }: Args, logger_prefix?: string)
console.log(shellcode())
break
case 'help':
setColorEnabled(clicolor(Deno.stdout.rid))
setColorEnabled(clicolor(Deno.stdout))
console.log(help(flags.verbosity))
break
case 'env': {
Expand Down Expand Up @@ -122,7 +122,7 @@ async function ensure_pantry() {

function make_logger(verbosity: number, logger_prefix?: string): IInstallLogger {
const logger = new Logger(logger_prefix)
if (verbosity <= -2 || !Deno.isatty(Deno.stderr.rid)) {
if (verbosity <= -2 || !Deno.stderr.isTerminal()) {
return {
replace: () => {},
clear: () => {},
Expand Down
4 changes: 2 additions & 2 deletions src/modes/integrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default async function(op: 'install' | 'uninstall', { dryrun }: { dryrun:
}
break
case 'install':
if (!_internals.isatty(Deno.stdout.rid)) {
if (!_internals.isatty(Deno.stdout)) {
// we're being sourced, output the hook
_internals.stdout(shellcode())
} else if (opd_at_least_once) {
Expand Down Expand Up @@ -125,7 +125,7 @@ function shells(): [Path, string][] {
export const _internals = {
home: Path.home,
host,
isatty: Deno.isatty,
isatty: (x: {isTerminal: () => boolean}) => x.isTerminal(),
stdout: console.log,
stderr: console.error
}
6 changes: 3 additions & 3 deletions src/utils/clicolor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

export default function(dst = Deno.stdout.rid, env = Deno.env.toObject()) {
export default function(dst = Deno.stdout, env = Deno.env.toObject()) {
// interprets https://no-color.org
// see: https://deno.land/api@v1.37.1?s=Deno.noColor
if (Deno.noColor) {
Expand All @@ -8,9 +8,9 @@ export default function(dst = Deno.stdout.rid, env = Deno.env.toObject()) {

//https://bixense.com/clicolors/

//NOTE we (mostly) only output colors to stderr hence the isatty check for that
//NOTE we (mostly) only output colors to stderr hence the isTerminal() check for that
//FIXME not true for --help tho
if (env.CLICOLOR !== '0' && Deno.isatty(dst)) {
if (env.CLICOLOR !== '0' && dst.isTerminal()) {
return true
}
if ((env.CLICOLOR_FORCE ?? '0') != '0') {
Expand Down
File renamed without changes.

0 comments on commit 3881796

Please sign in to comment.