Skip to content

Commit

Permalink
Support for narn exec
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldenning committed Mar 19, 2022
1 parent cd24c5d commit 80e5740
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/narn-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ exports.getNpmArgs = (narnArgs, isPnpm = false) => {
npmTarget = "info";
npmArgs = narnArgs.slice(1);
break;
case "exec":
npmTarget = "exec";
npmArgs = yarnSubCommands;
break;
default:
npmTarget = "run";
if (narnArgs.length > 1) {
Expand Down Expand Up @@ -188,8 +192,9 @@ function transformNarnPackageString(packageToAdd) {
? packageToAdd.lastIndexOf("@")
: packageToAdd.length + 1
);
const isValidPackageName = validateNpmPackageName(packageNameWithoutVersion)
.validForNewPackages;
const isValidPackageName = validateNpmPackageName(
packageNameWithoutVersion
).validForNewPackages;
if (isValidPackageName && packageNameWithoutVersion === packageToAdd) {
return `${packageToAdd}@latest`;
} else {
Expand Down
11 changes: 11 additions & 0 deletions test/exec.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { getNpmArgs } = require("../lib/narn-lib");

describe("narn exec", () => {
it("can exec with narn", () => {
expect(getNpmArgs(["exec", "changeset", "init"])).toEqual([
"exec",
"changeset",
"init",
]);
});
});

0 comments on commit 80e5740

Please sign in to comment.