Skip to content
Open
Show file tree
Hide file tree
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
21 changes: 12 additions & 9 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: ${{ matrix.kind }} ${{ matrix.os }}
name: Deno ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, '[skip ci]')"
strategy:
Expand All @@ -16,24 +19,24 @@ jobs:
DENO_BUILD_MODE: release
V8_BINARY: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- name: Setup Deno
uses: denolib/setup-deno@master
uses: denoland/setup-deno@v2
with:
deno-version: 1.x
deno-version: 2.x
- name: Tests
run: deno test --allow-run --allow-net
release:
name: Release
runs-on: ubuntu-18.04
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
if: "github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v6
with:
node-version: 12.17.0
node-version: 20
- name: Setup package.json
run: echo '{"name":"@denorg/dpx","version":"0.0.0","publishConfig":{"access":"public"},"scripts":{"semantic-release":"semantic-release"},"repository":{"type":"git","url":"https://github.com/denorg/dpx.git"},"author":"Denorg <hi@den.org.in>","license":"MIT","bugs":{"url":"https://github.com/denorg/dpx/issues"},"homepage":"https://denorg.github.io/dpx/","devDependencies":{"semantic-release":"^17.0.4","semantic-release-gitmoji":"^1.3.3"}}' > package.json
- name: Install dependencies
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

12 changes: 6 additions & 6 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getRegistryUrl } from "./src/utils.ts"
import { getRegistryUrl } from "./src/utils.ts";

/** Get the file URL to run */
export async function getEntryFile(packageName: string, registry?: string) {
let repo_url = getRegistryUrl(packageName, registry)
let repo_url = getRegistryUrl(packageName, registry);
const potentialFiles = ["cli.ts", "mod.ts"];
let fileUrl = "";
for await (const file of potentialFiles) {
Expand Down Expand Up @@ -31,13 +31,13 @@ export async function dpx(
packageName: string,
flags: string[],
args: string[],
registry?: string
registry?: string,
) {
const filePath = await getEntryFile(packageName, registry);
return Deno.run({
cmd: ["deno", "run", ...flags, filePath, ...args],
return new Deno.Command("deno", {
args: ["run", ...flags, filePath, ...args],
stdout: "inherit",
stderr: "inherit",
stdin: "inherit",
}).status();
}).spawn().status;
}
33 changes: 28 additions & 5 deletions mod_test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { getEntryFile } from "./mod.ts";
import { dpx, getEntryFile } from "./mod.ts";

Deno.test(
"get entry file - cli.ts",
async (): Promise<void> => {
assertEquals(
await getEntryFile("online"),
"https://deno.land/x/online/cli.ts"
"https://deno.land/x/online/cli.ts",
);
}
},
);

Deno.test(
"get entry file - mod.ts",
async (): Promise<void> => {
assertEquals(
await getEntryFile("recursive_readdir"),
"https://deno.land/x/recursive_readdir/mod.ts"
"https://deno.land/x/recursive_readdir/mod.ts",
);
}
},
);

Deno.test("dpx runs a CLI from a custom registry", async () => {
const server = Deno.serve({ port: 0 }, (request) => {
const { pathname } = new URL(request.url);
if (pathname === "/package/cli.ts") {
return new Response('console.log("dpx test CLI");');
}
return new Response("Not found", { status: 404 });
});
const { port } = server.addr as Deno.NetAddr;

try {
const status = await dpx(
"package",
[`--allow-net=127.0.0.1:${port}`],
[],
`http://127.0.0.1:${port}`,
);
assertEquals(status.success, true);
} finally {
await server.shutdown();
}
});