mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
chore: UPdate the shell
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Effects } from "../../types";
|
||||
import { parseCommand } from "../../util/parseCommand";
|
||||
import { CheckResult } from "./CheckResult";
|
||||
export function containsAddress(x: string, port: number) {
|
||||
const readPorts = x
|
||||
@@ -25,8 +26,14 @@ export async function checkPortListening(
|
||||
} = {}
|
||||
): Promise<CheckResult> {
|
||||
const hasAddress =
|
||||
containsAddress(await effects.shell("cat /proc/net/tcp"), port) ||
|
||||
containsAddress(await effects.shell("cat /proc/net/udp"), port);
|
||||
containsAddress(
|
||||
await effects.runCommand(parseCommand("cat /proc/net/tcp")),
|
||||
port
|
||||
) ||
|
||||
containsAddress(
|
||||
await effects.runCommand(parseCommand("cat /proc/net/udp")),
|
||||
port
|
||||
);
|
||||
if (hasAddress) {
|
||||
return { status: "passing", message };
|
||||
}
|
||||
|
||||
@@ -129,10 +129,6 @@ export type Effects = {
|
||||
path: string;
|
||||
}): Promise<Record<string, unknown>>;
|
||||
|
||||
shell(
|
||||
command: string,
|
||||
options?: { timeoutMillis?: number | null }
|
||||
): Promise<string>;
|
||||
runCommand(input: {
|
||||
command: string;
|
||||
args?: string[];
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as T from "../types";
|
||||
export { guardAll, typeFromProps } from "./propertiesMatcher";
|
||||
export { default as nullIfEmpty } from "./nullIfEmpty";
|
||||
export { FileHelper } from "./fileHelper";
|
||||
export { sh } from "./shell";
|
||||
export { parseCommand as sh } from "./parseCommand";
|
||||
|
||||
/** Used to check if the file exists before hand */
|
||||
export const exists = (
|
||||
|
||||
@@ -46,7 +46,10 @@ const quoteSeperated = (s: string, quote: typeof quotes) => {
|
||||
return values;
|
||||
};
|
||||
|
||||
export function sh(shellCommand: string) {
|
||||
type ValidIfNoStupidEscape<A> = A extends `${string}'"'"'${string}` ? never : A;
|
||||
export function parseCommand<T extends string>(
|
||||
shellCommand: ValidIfNoStupidEscape<T>
|
||||
) {
|
||||
const [command, ...args] = quoteSeperated(shellCommand, quotes).filter(
|
||||
Boolean
|
||||
);
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "start-sdk",
|
||||
"version": "0.4.0-lib0.charlie8",
|
||||
"version": "0.4.0-lib0.charlie9",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "start-sdk",
|
||||
"version": "0.4.0-lib0.charlie8",
|
||||
"version": "0.4.0-lib0.charlie9",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^2.2.5",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "start-sdk",
|
||||
"version": "0.4.0-lib0.charlie8",
|
||||
"version": "0.4.0-lib0.charlie9",
|
||||
"description": "For making the patterns that are wanted in making services for the startOS.",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user