From c753cc20805ac3cc3674607936ce6aa519821d81 Mon Sep 17 00:00:00 2001 From: Joel Denning Date: Sat, 8 Feb 2020 11:07:59 -0700 Subject: [PATCH] Adding support for yarn create (#16) * Adding support for yarn create * Self review --- README.md | 3 +++ lib/narn-lib.js | 4 ++++ test/create.test.js | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 test/create.test.js diff --git a/README.md b/README.md index bcb267c..7bcbe77 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,9 @@ narn upgrade-interactive --latest # Install global library. All global libs are installed with yarn (since the most important thing is just that you consistently use the same package manager for global libs) narn global add @vue/cli +# yarn create single-spa is similar to npm init single-spa +narn create single-spa + # View the installed versions of narn and yarn/npm narn -v narn --version diff --git a/lib/narn-lib.js b/lib/narn-lib.js index d7bafc8..b145e1d 100644 --- a/lib/narn-lib.js +++ b/lib/narn-lib.js @@ -79,6 +79,10 @@ exports.getNpmArgs = (narnArgs, isPnpm = false) => { result.command = "ncu"; return result; } + case "create": + npmTarget = "init"; + npmArgs = yarnSubCommands; + break; case "publish": result = []; result.command = "np"; diff --git a/test/create.test.js b/test/create.test.js new file mode 100644 index 0000000..0dccb2f --- /dev/null +++ b/test/create.test.js @@ -0,0 +1,17 @@ +const { getNpmArgs } = require("../lib/narn-lib"); + +describe("narn create", () => { + it("can run create-single-spa package with npm", () => { + expect(getNpmArgs(["create", "single-spa"])).toEqual([ + "init", + "single-spa" + ]); + }); + + it("can run a create-thing package with pnpm", () => { + expect(getNpmArgs(["create", "single-spa"], true)).toEqual([ + "init", + "single-spa" + ]); + }); +});