-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle platform specific provides yml
- Loading branch information
Showing
3 changed files
with
24 additions
and
7 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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#!/usr/bin/env -S pkgx deno run --allow-read=. --allow-net | ||
|
||
import * as yaml from "https://deno.land/[email protected]/yaml/mod.ts"; | ||
import { isArray, isString } from "https://deno.land/x/[email protected]/src/index.ts"; | ||
import get_pkg_name from "./utils/get-name.ts" | ||
import get_provides from "./utils/get-provides.ts" | ||
import { basename } from "path"; | ||
|
||
interface Package { | ||
project: string | ||
|
@@ -24,7 +25,8 @@ export async function getKettleRemoteMetadata() { | |
} | ||
|
||
function get_name(yml: any, project: string) { | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides: yml['provides'] }) | ||
const provides = get_provides(yml) | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides }) | ||
} | ||
|
||
|
||
|
@@ -37,11 +39,8 @@ for (const obj of rv as Package[]) { | |
const txt = await Deno.readTextFileSync(yaml_path) | ||
const yml = await yaml.parse(txt) as Record<string, any> | ||
|
||
const node = yml['provides'] | ||
const provides: string[] = isArray(node) ? node : isString(node) ? [node] : [] | ||
|
||
obj.displayName = get_name(yaml_path, obj.project) | ||
obj.programs = provides.map(x => x.slice(4)) | ||
obj.programs = get_provides(yml).map(x => basename(x)) | ||
} catch (err) { | ||
console.warn(`::warning::${err.message}`) | ||
} | ||
|
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 |
---|---|---|
|
@@ -75,12 +75,14 @@ console.log(JSON.stringify(pkgs, null, 2)); | |
|
||
////////////////////////////////////////////////////// | ||
import { parse } from "https://deno.land/[email protected]/yaml/mod.ts"; | ||
import get_provides from "./utils/get-provides.ts"; | ||
import get_pkg_name from "./utils/get-name.ts"; | ||
|
||
async function get_name(path: string, project: string): Promise<string | undefined> { | ||
const txt = await Deno.readTextFileSync(path) | ||
const yml = await parse(txt) as Record<string, any> | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides: yml['provides'] }) | ||
const provides = get_provides(yml) | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides }) | ||
} | ||
|
||
import { parse_pkgs_node } from "https://deno.land/x/[email protected]/src/hooks/usePantry.ts" | ||
|
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,16 @@ | ||
import { isString, isPlainObject } from "https://deno.land/x/[email protected]/src/index.ts"; | ||
|
||
export default function get_provides(yml: any): string[] { | ||
let provides = yml['provides'] | ||
if (isString(provides)) { | ||
return [provides] | ||
} | ||
if (isPlainObject(provides)) { | ||
const { darwin, linux, windows } = provides | ||
provides = [] | ||
for (const x of [darwin, linux, windows]) { | ||
if (x) provides.push(...x) | ||
} | ||
} | ||
return provides | ||
} |