diff --git a/README.md b/README.md index cec7bbc..5f71637 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ [![npm version](https://img.shields.io/npm/v/create-nodew-exe.svg)](https://www.npmjs.com/package/create-nodew-exe) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -# create-nodew-exe (use v1 for legacy node versions!) +# create-nodew-exe + +**_Use v1 for legacy node versions!_** Creates an executable based on node.exe that will not show a terminal on launch (sometimes also called "silent mode"). @@ -13,20 +15,22 @@ Credit for originally discovering how to do this goes to: [@ukoloff](https://git The conversion can be done on any platform, Windows is **not** required. -Either through the CLI: -``` -yarn global add create-nodew-exe +Either through the CLI, e.g.: +```bash +pnpm add --global create-nodew-exe create-nodew-exe ``` ... or locally in your project: +```bash +pnpm add -D create-nodew-exe ``` -yarn add create-nodew-exe -``` -``` -require('create-nodew-exe')({ - src: 'path/to/source', - dst: 'path/to/destination', +```ts +import { createNodewExe } from "create-nodew-exe"; + +createNodewExe({ + src: 'path/to/source', + dst: 'path/to/destination', }); ``` diff --git a/bin/cli.ts b/bin/cli.ts index 9916ba5..cf90d42 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import yargs from "yargs"; import { hideBin } from "yargs/helpers"; -import { main } from "../src/main.js"; +import { createNodewExe } from "../src/main.js"; const argv = yargs(hideBin(process.argv)) .usage( @@ -19,7 +19,7 @@ const argv = yargs(hideBin(process.argv)) .parseSync(); console.log("Generating: ", argv._[1]); -main({ +createNodewExe({ src: String(argv._[0]), dst: String(argv._[1]), }); diff --git a/e2e/index.ts b/e2e/index.ts index 4fc72df..96a0c24 100644 --- a/e2e/index.ts +++ b/e2e/index.ts @@ -2,7 +2,7 @@ import screenshot from "screenshot-desktop"; import { Canvas, loadImage } from "skia-canvas"; import { mkdir, unlink, writeFile } from "node:fs/promises"; import { basename } from "path"; -import { main } from "../src/main.js"; +import { createNodewExe } from "../src/main.js"; import { execa } from "execa"; import { execPath } from "node:process"; @@ -68,7 +68,7 @@ await mkdir("e2e-output"); const regularExecutable = execPath; const silentExecutable = "bin\\testData\\nodew.exe"; -main({ +createNodewExe({ src: regularExecutable, dst: silentExecutable, }); diff --git a/src/main.test.ts b/src/main.test.ts index dbc361f..98373db 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -1,9 +1,9 @@ // The case of successful file conversion is covered in cli.test.js -import { main } from "./main.js"; +import { createNodewExe } from "./main.js"; test("input file doesn't exist", () => { try { - main({ + createNodewExe({ src: "doesntexist", dst: "doesntmatter", }); @@ -16,7 +16,7 @@ test("input file doesn't exist", () => { test("input file is invalid", () => { try { - main({ + createNodewExe({ src: "./package.json", dst: "doesntmatter", }); diff --git a/src/main.ts b/src/main.ts index 9f3e283..90e3d77 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import fs from "fs"; import { toInt } from "./hex.js"; -export function main({ src, dst }: { src: string; dst: string }) { +export function createNodewExe({ src, dst }: { src: string; dst: string }) { let buffer: Buffer; let pos = 0; // current position within buffer