Skip to content

Commit

Permalink
style: lint bin script as well
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Sep 24, 2024
1 parent eca702e commit f525bf5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
54 changes: 30 additions & 24 deletions bin/smee.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
#!/usr/bin/env node

import { program } from 'commander'
import { readFile } from 'node:fs/promises'
import Client from '../index.js'
import { program } from "commander";
import { readFile } from "node:fs/promises";
import Client from "../index.js";

const { version } = JSON.parse(await readFile(new URL('../package.json', import.meta.url)))
const { version } = JSON.parse(
await readFile(new URL("../package.json", import.meta.url)),
);

program
.version(version, '-v, --version')
.usage('[options]')
.option('-u, --url <url>', 'URL of the webhook proxy service. Default: https://smee.io/new')
.option('-t, --target <target>', 'Full URL (including protocol and path) of the target service the events will forwarded to. Default: http://127.0.0.1:PORT/PATH')
.option('-p, --port <n>', 'Local HTTP server port', process.env.PORT || 3000)
.option('-P, --path <path>', 'URL path to post proxied requests to`', '/')
.parse(process.argv)

const opts = program.opts()

const {
target = `http://127.0.0.1:${opts.port}${opts.path}`
} = opts

async function setup () {
let source = opts.url
.version(version, "-v, --version")
.usage("[options]")
.option(
"-u, --url <url>",
"URL of the webhook proxy service. Default: https://smee.io/new",
)
.option(
"-t, --target <target>",
"Full URL (including protocol and path) of the target service the events will forwarded to. Default: http://127.0.0.1:PORT/PATH",
)
.option("-p, --port <n>", "Local HTTP server port", process.env.PORT || 3000)
.option("-P, --path <path>", "URL path to post proxied requests to`", "/")
.parse(process.argv);

const opts = program.opts();

const { target = `http://127.0.0.1:${opts.port}${opts.path}` } = opts;

async function setup() {
let source = opts.url;

if (!source) {
source = await Client.createChannel()
source = await Client.createChannel();
}

const client = new Client({ source, target })
client.start()
const client = new Client({ source, target });
client.start();
}

setup()
setup();
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
],
"scripts": {
"build": "tsc -p tsconfig.json",
"lint": "prettier --check \"index.ts\" \"test/**/*.ts\" package.json tsconfig.json --end-of-line auto",
"lint:fix": "prettier --write \"index.ts\" \"test/**/*.ts\" package.json tsconfig.json --end-of-line auto",
"lint": "prettier --check \"index.ts\" \"test/**/*.ts\" bin/smee.js package.json tsconfig.json --end-of-line auto",
"lint:fix": "prettier --write \"index.ts\" \"test/**/*.ts\" bin/smee.js package.json tsconfig.json --end-of-line auto",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:dev": "vitest --ui --coverage"
Expand Down

0 comments on commit f525bf5

Please sign in to comment.