Skip to content

Commit 1c7938a

Browse files
author
Raul Melo
committed
Add bin.mjs and update package.json
1 parent 589c530 commit 1c7938a

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

scripts/npm.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ func main() {
6060
return
6161
}
6262

63+
fmt.Println("README.md copied")
64+
6365
err = copyFile(
6466
"./scripts/templates/install-manager.mjs",
6567
outDir,
@@ -71,7 +73,21 @@ func main() {
7173
return
7274
}
7375

74-
fmt.Println("README.md copied")
76+
fmt.Println("install-manager.mjs copied")
77+
78+
err = copyFile(
79+
"./scripts/templates/bin.mjs",
80+
outDir,
81+
"bin.mjs",
82+
)
83+
84+
if err != nil {
85+
fmt.Println("[ERROR] [copy bin.mjs] ", err)
86+
return
87+
}
88+
89+
fmt.Println("bin.mjs copied")
90+
7591
}
7692

7793
func getDistFolderPath() (string, error) {

scripts/templates/bin.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
import { execSync } from "child_process";
4+
import { fileURLToPath } from "url";
5+
import path from "path";
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
10+
const fullPath = path.join(__dirname, "bin/node-versions-cli");
11+
12+
// Get the arguments passed to the script, excluding the first two elements
13+
// The first element is the path to the node executable
14+
// The second element is the path to your script
15+
const args = process.argv.slice(2);
16+
17+
// Join the arguments into a single string
18+
const argsString = args.join(" ");
19+
20+
execSync(`${fullPath} ${argsString}`, { stdio: "inherit" });

scripts/templates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@raulfdm/node-versions",
33
"private": false,
44
"bin": {
5-
"node-versions": "./bin/node-versions"
5+
"node-versions": "bin.mjs"
66
},
77
"publishConfig": {
88
"access": "public"

0 commit comments

Comments
 (0)