Skip to content

Commit

Permalink
make index.ts runnable directly
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Jul 23, 2024
1 parent 4323686 commit 954f6c2
Show file tree
Hide file tree
Showing 4 changed files with 571 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ build: node_modules $(DIST_FILES)

$(DIST_FILES): $(SOURCE_FILES) package-lock.json vite.config.ts
npx vite build
@sed -i "1s/.*/\#\!\/usr\/bin\/env node/" dist/index.js
chmod +x $(DIST_FILES)

.PHONY: publish
Expand Down
6 changes: 3 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env -S node --import @swc-node/register/esm-register
import ansiRegex from "ansi-regex";
import minimist from "minimist";
import rat from "registry-auth-token";
Expand All @@ -16,7 +16,7 @@ import {getProperty} from "dot-prop";
import pAll from "p-all";
import memize from "memize";
import picomatch from "picomatch";
import {version} from "./package.json" with {type: "json"};
import pkg from "./package.json" with {type: "json"};
import type {AuthOptions} from "registry-auth-token";
import type {AgentOptions} from "node:https";

Expand Down Expand Up @@ -82,7 +82,7 @@ const esc = (str: string) => str.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&");
const gitInfo = memize(hostedGitInfo.fromUrl);
const registryAuthToken = memize(rat);
const normalizeUrl = memize((url: string) => url.endsWith("/") ? url.substring(0, url.length - 1) : url);
const packageVersion = version || "0.0.0";
const packageVersion = pkg.version || "0.0.0";
const sep = "\0";

const args = minimist(argv.slice(2), {
Expand Down
Loading

0 comments on commit 954f6c2

Please sign in to comment.