Skip to content

Commit

Permalink
Fix no effect when run through npx etc.
Browse files Browse the repository at this point in the history
We *badly* need an import.meta.main.

nodejs/node#49440
  • Loading branch information
kisaragi-hiu committed Sep 22, 2024
1 parent 824039a commit 1d33b4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# use-license

# 0.1.0 (2024-09-22)
## 0.1.1 (2024-09-22)

Fix the command doing nothing when run through npx.

## 0.1.0 (2024-09-22)

Initial release.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-license",
"version": "0.1.0",
"version": "0.1.1",
"description": "Download license via SPDX identifier",
"type": "module",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import { existsSync, writeFileSync, writeSync } from "node:fs"
import { existsSync, realpathSync, writeFileSync, writeSync } from "node:fs"
import { parseArgs } from "node:util"
import open from "open"
import pkg from "../package.json"
Expand Down Expand Up @@ -100,6 +100,6 @@ Options:
}
}

if (process.argv[1] === import.meta.filename) {
if (realpathSync(process.argv[1]) === import.meta.filename) {
main()
}

0 comments on commit 1d33b4d

Please sign in to comment.