Skip to content

Commit d743707

Browse files
committed
Support for narnx
1 parent a445a77 commit d743707

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ narn create single-spa
5656
# View the installed versions of narn and yarn/npm
5757
narn -v
5858
narn --version
59+
60+
# global commands are supported too
61+
narnx global add http-server
62+
narnx global remove http-server
63+
64+
# Run npx / pnpx
65+
narnx create-single-spa
5966
```
6067

6168
For more usage, see the [Yarn CLI docs](https://yarnpkg.com/lang/en/docs/cli/) - `narn`'s cli is meant to behave exactly the same.

bin/narnx.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env node
2+
const { spawn } = require("child_process");
3+
4+
const narnxArgs = process.argv.slice(2);
5+
let command;
6+
7+
if (process.env.NARN_DEFAULT_PM === "pnpm") {
8+
command = "pnpx";
9+
} else if (process.env.NARN_DEFAULT_PM === "npm") {
10+
command = "npx";
11+
} else {
12+
command = "npx";
13+
}
14+
15+
console.info(`${command} ${narnxArgs.join(" ")}`);
16+
spawn(command, narnxArgs, { stdio: "inherit", shell: true });

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "2.0.0",
44
"main": "lib/narn-lib.js",
55
"bin": {
6-
"narn": "bin/narn.js"
6+
"narn": "bin/narn.js",
7+
"narnx": "bin/narnx.js"
78
},
89
"repository": "[email protected]:joeldenning/narn.git",
910
"author": "Joel Denning <[email protected]>",

0 commit comments

Comments
 (0)