Skip to content

Commit

Permalink
Adapt to new elm-format behaviour for (..) expansion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lattyware committed Sep 23, 2019
1 parent e713452 commit 29a1f11
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
49 changes: 27 additions & 22 deletions src/js/template/elm.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`;
11 changes: 7 additions & 4 deletions src/js/template/styles.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,5 +23,5 @@ import Html exposing (Html)
-}
css : Html msg
css = Html.node "style" [] [ Html.text "${css}" ]
`);

`
);

0 comments on commit 29a1f11

Please sign in to comment.