diff --git a/src/cert.ts b/src/cert.ts index 601c05c..2579c93 100644 --- a/src/cert.ts +++ b/src/cert.ts @@ -20,7 +20,7 @@ export interface SSLCertOptions { } export async function generateSSLCert( - options: SSLCertOptions + options: SSLCertOptions, ): Promise { // Certificate Attributes (https://git.io/fptna) const attributes = [ @@ -75,7 +75,7 @@ export interface CAOptions { } export async function generateCA( - options: CAOptions = {} + options: CAOptions = {}, ): Promise { // Certificate Attributes: https://git.io/fptna const attributes = [ @@ -117,7 +117,7 @@ export async function generateCert(options: CertOptions): Promise { // Create serial from and integer between 50000 and 99999 const serial = Math.floor(Math.random() * 95_000 + 50_000).toString(); const generateKeyPair = promisify( - forge.pki.rsa.generateKeyPair.bind(forge.pki.rsa) + forge.pki.rsa.generateKeyPair.bind(forge.pki.rsa), ); const keyPair = await generateKeyPair({ bits: 2048, workers: 4 }); const cert = forge.pki.createCertificate(); @@ -127,7 +127,7 @@ export async function generateCert(options: CertOptions): Promise { cert.validity.notBefore = new Date(); cert.validity.notAfter = new Date(); cert.validity.notAfter.setDate( - cert.validity.notAfter.getDate() + options.validityDays + cert.validity.notAfter.getDate() + options.validityDays, ); cert.setSubject(options.subject); cert.setIssuer(options.issuer); diff --git a/src/index.ts b/src/index.ts index 70dce47..c0a2e63 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,7 +57,7 @@ export interface Listener { export async function listen( handle: RequestListener, - options_: Partial = {} + options_: Partial = {}, ): Promise { options_ = defu(options_, { port: process.env.PORT || 3000, @@ -104,7 +104,7 @@ export async function listen( if (options_.https) { const { key, cert } = await resolveCert( { ...(options_.https as any) }, - options_.hostname + options_.hostname, ); https = { key, cert }; server = createHTTPSServer({ key, cert }, handle); @@ -148,7 +148,9 @@ export async function listen( const anyV6 = addr?.addr === "[::]"; if (anyV4 || anyV6) { lines.push( - ` > Local${name}: ${formatURL(getURL("localhost", baseURL))} ${add}` + ` > Local${name}: ${formatURL( + getURL("localhost", baseURL), + )} ${add}`, ); for (const addr of getNetworkInterfaces(anyV4)) { lines.push(` > Network${name}: ${formatURL(getURL(addr, baseURL))}`); @@ -156,8 +158,8 @@ export async function listen( } else { lines.push( ` > Listening${name}: ${formatURL( - getURL(undefined, baseURL) - )} ${add}` + getURL(undefined, baseURL), + )} ${add}`, ); } // eslint-disable-next-line no-console @@ -191,7 +193,7 @@ export async function listen( async function resolveCert( options: HTTPSOptions, - host?: string + host?: string, ): Promise { // Use cert if provided if (options.key && options.cert) { @@ -244,6 +246,6 @@ function formatAddress(addr: { family: string | number; address: string }) { function formatURL(url: string) { return cyan( - underline(decodeURI(url).replace(/:(\d+)\//g, `:${bold("$1")}/`)) + underline(decodeURI(url).replace(/:(\d+)\//g, `:${bold("$1")}/`)), ); } diff --git a/src/lib/open/index.ts b/src/lib/open/index.ts index 4a1c4d1..3ae262a 100644 --- a/src/lib/open/index.ts +++ b/src/lib/open/index.ts @@ -54,7 +54,7 @@ const getWslDrivesMountPoint = (() => { encoding: "utf8", }); const configMountPoint = /(?.*)/g.exec( - configContent + configContent, ); if (!configMountPoint) { @@ -96,7 +96,7 @@ const baseOpen = async (options) => { baseOpen({ ...options, app: singleApp, - }) + }), ); } @@ -112,7 +112,7 @@ const baseOpen = async (options) => { name: appName, arguments: appArguments, }, - }) + }), ); } @@ -150,7 +150,7 @@ const baseOpen = async (options) => { "-NonInteractive", "–ExecutionPolicy", "Bypass", - "-EncodedCommand" + "-EncodedCommand", ); if (!isWsl()) { @@ -182,7 +182,7 @@ const baseOpen = async (options) => { // Using Base64-encoded command, accepted by PowerShell, to allow special characters. options.target = Buffer.from( encodedArguments.join(" "), - "utf16le" + "utf16le", ).toString("base64"); } else { if (app) { @@ -198,7 +198,7 @@ const baseOpen = async (options) => { writeFileSync( join(os.tmpdir(), "xdg-open"), await import("./xdg-open").then((r) => r.xdgOpenScript()), - "utf8" + "utf8", ); chmodSync(command, 0o755 /* rwx r-x r-x */); } catch { @@ -231,7 +231,7 @@ const baseOpen = async (options) => { const subprocess = childProcess.spawn( command, cliArguments, - childProcessOptions + childProcessOptions, ); if (options.wait) { @@ -331,8 +331,8 @@ defineLazyProperty(apps, "chrome", () => "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe", ], }, - } - ) + }, + ), ); defineLazyProperty(apps, "firefox", () => @@ -344,8 +344,8 @@ defineLazyProperty(apps, "firefox", () => }, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe", - } - ) + }, + ), ); defineLazyProperty(apps, "edge", () => @@ -357,8 +357,8 @@ defineLazyProperty(apps, "edge", () => }, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe", - } - ) + }, + ), ); open.apps = apps; diff --git a/test/fixture/app.ts b/test/fixture/app.ts index 1fe0841..b280065 100644 --- a/test/fixture/app.ts +++ b/test/fixture/app.ts @@ -6,8 +6,8 @@ listen( }, { open: process.argv.some( - (argument) => argument === "-o" || argument === "--open" + (argument) => argument === "-o" || argument === "--open", ), https: process.argv.includes("--https"), - } + }, );