From 29a1f1142d417aad431254803bac84e87570ed6a Mon Sep 17 00:00:00 2001 From: Gareth Latty Date: Mon, 23 Sep 2019 15:16:04 +0100 Subject: [PATCH] Adapt to new elm-format behaviour for `(..)` expansion. --- src/js/template/elm.js | 49 +++++++++++++++++++++------------------ src/js/template/styles.js | 11 +++++---- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/js/template/elm.js b/src/js/template/elm.js index c7a5957..86de3ee 100644 --- a/src/js/template/elm.js +++ b/src/js/template/elm.js @@ -1,24 +1,31 @@ -export const packageDefinition = (version, modules) => JSON.stringify({ - "type": "package", - "name": "lattyware/elm-fontawesome", - "summary": "FontAwesome 5 SVG icons.", - "license": "MIT", - "version": version, - "exposed-modules": modules.map(moduleName), - "elm-version": "0.19.0 <= v < 0.20.0", - "dependencies": { - "elm/core": "1.0.2 <= v < 2.0.0", - "elm/html": "1.0.0 <= v < 2.0.0", - "elm/svg": "1.0.1 <= v < 2.0.0" - }, - "test-dependencies": {} -}, null, 2); +export const packageDefinition = (version, modules) => + JSON.stringify( + { + type: "package", + name: "lattyware/elm-fontawesome", + summary: "FontAwesome 5 SVG icons.", + license: "MIT", + version: version, + "exposed-modules": modules.map(moduleName), + "elm-version": "0.19.0 <= v < 0.20.0", + dependencies: { + "elm/core": "1.0.2 <= v < 2.0.0", + "elm/html": "1.0.0 <= v < 2.0.0", + "elm/svg": "1.0.1 <= v < 2.0.0" + }, + "test-dependencies": {} + }, + null, + 2 + ); -export const module = (path, body, exposing=[".."]) => (` -module ${moduleName(path)} exposing (${exposing.join(", ")}) +export const module = (path, body, exposing = null) => ` +module ${moduleName(path)}${ + exposing == null ? "" : ' exposing (${exposing.join(", ")})' +} ${body} -`); +`; export function identifier(str) { const capWords = str @@ -29,8 +36,6 @@ export function identifier(str) { return /^\p{Ll}.*$/u.test(camelCase) ? camelCase : "fa" + camelCase; } -export const moduleName = (path) => - path.join("."); +export const moduleName = path => path.join("."); -export const moduleFileName = (path) => - `${path.join("/")}.elm`; +export const moduleFileName = path => `${path.join("/")}.elm`; diff --git a/src/js/template/styles.js b/src/js/template/styles.js index f0fed3f..d641997 100644 --- a/src/js/template/styles.js +++ b/src/js/template/styles.js @@ -1,12 +1,15 @@ import * as elm from "./elm"; -import {dom} from "@fortawesome/fontawesome-svg-core"; +import { dom } from "@fortawesome/fontawesome-svg-core"; const css = dom .css() .replace(/(\r\n\t|\n|\r\t)/gm, "") .replace(/"/g, '\\"'); -export const styles = (path) => elm.module(path, ` +export const styles = path => + elm.module( + path, + ` {-| Helpers for adding the CSS required for FontAwesome to your page. @docs css @@ -20,5 +23,5 @@ import Html exposing (Html) -} css : Html msg css = Html.node "style" [] [ Html.text "${css}" ] -`); - +` + );