From f9dbd4e4dd0955062c206283b19c26ee14179c74 Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Wed, 6 Sep 2017 16:53:29 -0700 Subject: [PATCH] expose "lib" (module w/o "primer-" prefix) --- modules/generator-primer-module/app/index.js | 8 +++----- .../generator-primer-module/app/templates/index.scss | 2 +- modules/generator-primer-module/test/generator.spec.js | 10 ++++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/generator-primer-module/app/index.js b/modules/generator-primer-module/app/index.js index bef2a447..441e01e6 100644 --- a/modules/generator-primer-module/app/index.js +++ b/modules/generator-primer-module/app/index.js @@ -159,7 +159,8 @@ module.exports = class PrimerModule extends Generator { return acc }, {}) - // this.log("data:", JSON.stringify(data, null, " ")) + // for the index.scss import + data.lib = stripPrimerPrefix(data.module) // copy the whole directory with each file treated as // an EJS template @@ -169,11 +170,8 @@ module.exports = class PrimerModule extends Generator { data ) - // rename lib/module.scss to lib/{name}.scss, where - // {name} is the module name without the "primer-" prefix - const name = stripPrimerPrefix(this.options.module) const src = path.join(this.basePath, "lib/module.scss") - const dest = src.replace("module.scss", `${name}.scss`) + const dest = src.replace("module.scss", `${data.lib}.scss`) this.fs.move(src, dest) } diff --git a/modules/generator-primer-module/app/templates/index.scss b/modules/generator-primer-module/app/templates/index.scss index 068732aa..566b61a3 100644 --- a/modules/generator-primer-module/app/templates/index.scss +++ b/modules/generator-primer-module/app/templates/index.scss @@ -1,3 +1,3 @@ // support files @import "primer-support/index.scss"; -@import "./lib/<%= module %>.scss"; +@import "./lib/<%= lib %>.scss"; diff --git a/modules/generator-primer-module/test/generator.spec.js b/modules/generator-primer-module/test/generator.spec.js index 27ff14c2..fa9c41c0 100644 --- a/modules/generator-primer-module/test/generator.spec.js +++ b/modules/generator-primer-module/test/generator.spec.js @@ -138,3 +138,13 @@ test("docs are filled in with file contents", t => { }) }) }) + +test("index.scss imports lib/{module}.scss", t => { + const module = "primer-select-menu" + const lib = "select-menu" + return generate({prompts: {module}}) + .then(path => { + assert.fileContent(path("index.scss"), `@import "./lib/${lib}.scss";`) + t.pass() + }) +})