Skip to content
Merged

typo #82

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 44 additions & 36 deletions pkgm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function standardPath() {
break;
case "linux":
homebrewPrefix = `/home/linuxbrew/.linuxbrew:${
Deno.env.get("HOME")
Deno.env.get(
"HOME",
)
}/.linuxbrew`;
break;
}
Expand Down Expand Up @@ -87,7 +89,7 @@ if (parsedArgs.help || parsedArgs._[0] == "help") {
{
let all_success = true;
for (const arg of args) {
if (!await uninstall(arg)) {
if (!(await uninstall(arg))) {
all_success = false;
}
}
Expand Down Expand Up @@ -132,8 +134,8 @@ async function install(args: string[], basePath: string) {
const pkgx = get_pkgx();

const [json] = await query_pkgx(pkgx, args);
const pkg_prefixes = json.pkgs.map((x) =>
`${x.pkg.project}/v${x.pkg.version}`
const pkg_prefixes = json.pkgs.map(
(x) => `${x.pkg.project}/v${x.pkg.version}`,
);

// get the pkgx_dir this way as it is a) more reliable and b) the only way if
Expand Down Expand Up @@ -200,9 +202,10 @@ async function install(args: string[], basePath: string) {
}

if (
!Deno.env.get("PATH")?.split(":")?.includes(
new Path(basePath).join("bin").string,
)
!Deno.env
.get("PATH")
?.split(":")
?.includes(new Path(basePath).join("bin").string)
) {
console.error(
"%c! warning:",
Expand Down Expand Up @@ -282,7 +285,7 @@ async function query_pkgx(
args = args.map((x) => `+${x}`);

const env: Record<string, string> = {
"PATH": standardPath(),
PATH: standardPath(),
};
const set = (key: string) => {
const x = Deno.env.get(key);
Expand Down Expand Up @@ -316,8 +319,7 @@ async function query_pkgx(
stdout: "piped",
env,
clearEnv: true,
})
.spawn();
}).spawn();

const status = await proc.status;

Expand All @@ -328,22 +330,24 @@ async function query_pkgx(
const out = await proc.output();
const json = JSON.parse(new TextDecoder().decode(out.stdout));

const pkgs =
(json.pkgs as { path: string; project: string; version: string }[]).map(
(x) => {
return {
path: new Path(x.path),
pkg: { project: x.project, version: new SemVer(x.version) },
};
},
);
const pkgs = (
json.pkgs as { path: string; project: string; version: string }[]
).map((x) => {
return {
path: new Path(x.path),
pkg: { project: x.project, version: new SemVer(x.version) },
};
});
const pkg = pkgs.find((x) => `+${x.pkg.project}` == args[0])!;
return [{
pkg,
pkgs,
env: json.env,
runtime_env: json.runtime_env,
}, env];
return [
{
pkg,
pkgs,
env: json.env,
runtime_env: json.runtime_env,
},
env,
];
}

async function mirror_directory(dst: string, src: string, prefix: string) {
Expand Down Expand Up @@ -465,10 +469,7 @@ async function create_v_symlinks(prefix: string) {
}
}

function expand_runtime_env(
json: JsonResponse,
basePath: string,
) {
function expand_runtime_env(json: JsonResponse, basePath: string) {
const { runtime_env, pkgs } = json;

//FIXME this combines all runtime env which is strictly overkill
Expand Down Expand Up @@ -498,7 +499,11 @@ function expand_runtime_env(

// DUMB but easiest way to fix a bug
const rv2: Record<string, Record<string, string>> = {};
for (const { pkg: { project } } of json.pkgs) {
for (
const {
pkg: { project },
} of json.pkgs
) {
rv2[project] = rv;
}

Expand Down Expand Up @@ -530,7 +535,10 @@ function get_pkgx() {

async function* ls() {
for (
const path of [new Path("/usr/local/pkgs"), Path.home().join(".local/pkgs")]
const path of [
new Path("/usr/local/pkgs"),
Path.home().join(".local/pkgs"),
]
) {
if (!path.isDirectory()) continue;
const dirs = [path];
Expand All @@ -554,7 +562,7 @@ async function uninstall(arg: string) {
found = (await hooks.usePantry().find(arg))?.[0];
} catch {
console.error(
"%ci pantry not found, trying to find package another way",
"%c pantry not found, trying to find package another way",
"color:blue",
);
}
Expand Down Expand Up @@ -671,8 +679,8 @@ async function outdated() {
for (const { path, pkg } of pkgs) {
const versions = await hooks.useInventory().get(pkg);
// console.log(pkg, graph[pkg.project]);
const constrained_versions = versions.filter((x) =>
graph[pkg.project].satisfies(x) && x.gt(pkg.version)
const constrained_versions = versions.filter(
(x) => graph[pkg.project].satisfies(x) && x.gt(pkg.version),
);
if (constrained_versions.length) {
console.log(
Expand Down Expand Up @@ -726,8 +734,8 @@ async function update() {

for (const { pkg } of pkgs) {
const versions = await hooks.useInventory().get(pkg);
const constrained_versions = versions.filter((x) =>
graph[pkg.project].satisfies(x) && x.gt(pkg.version)
const constrained_versions = versions.filter(
(x) => graph[pkg.project].satisfies(x) && x.gt(pkg.version),
);

if (constrained_versions.length) {
Expand Down
Loading