Skip to content

Commit

Permalink
Merge pull request #13 from lydell/update-elm-format
Browse files Browse the repository at this point in the history
Update to elm-format 0.8.7 and support installation in Fish shell
  • Loading branch information
ryan-haskell authored Aug 6, 2023
2 parents 2df2660 + f1dbb77 commit edf2ac0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
},
"dependencies": {
"elm": "0.19.1-5",
"elm-format": "0.8.5"
"elm-format": "0.8.7"
},
"devDependencies": {
"@types/node": "18.11.18",
Expand Down
32 changes: 16 additions & 16 deletions src/features/elm-format-on-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const feature: Feature = ({ context }) => {
context.subscriptions.push(
vscode.commands.registerCommand('elmLand.installElmFormat', () => {
const terminal = vscode.window.createTerminal(`Install elm-format`)
terminal.sendText(`(cd ${os.homedir()} && npm install -g [email protected].5)`)
terminal.sendText(`npm install -g [email protected].7`)
terminal.show()
})
)
Expand Down Expand Up @@ -44,23 +44,23 @@ function runElmFormat(document: vscode.TextDocument): Promise<string> {
env: sharedLogic.npxEnv()
},
async (err, stdout, stderr) => {
if (err) {
const ELM_FORMAT_BINARY_NOT_FOUND = 127
if (err.code === ELM_FORMAT_BINARY_NOT_FOUND || err.message.includes(`'elm-format' is not recognized`)) {
let response = await vscode.window.showWarningMessage(
'The "Format on save" feature requires "elm-format"',
{ modal: false },
'Install'
)
if (response === 'Install') {
vscode.commands.executeCommand('elmLand.installElmFormat')
if (err) {
const ELM_FORMAT_BINARY_NOT_FOUND = 127
if (err.code === ELM_FORMAT_BINARY_NOT_FOUND || err.message.includes(`'elm-format' is not recognized`)) {
let response = await vscode.window.showWarningMessage(
'The "Format on save" feature requires "elm-format"',
{ modal: false },
'Install'
)
if (response === 'Install') {
vscode.commands.executeCommand('elmLand.installElmFormat')
}
}
reject(err)
} else {
resolve(stdout)
}
reject(err)
} else {
resolve(stdout)
}
})
})
process_.stdin?.write(original)
process_.stdin?.end()
return process_
Expand Down
4 changes: 2 additions & 2 deletions src/features/error-highlighting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const feature: Feature = ({ globalState, context }) => {
context.subscriptions.push(
vscode.commands.registerCommand('elmLand.installElm', () => {
const terminal = vscode.window.createTerminal(`Install elm`)
terminal.sendText(`(cd ${os.homedir()} && npm install -g [email protected])`)
terminal.sendText(`npm install -g [email protected]`)
terminal.show()
})
)
Expand Down Expand Up @@ -411,4 +411,4 @@ const toDiagnosticItem = ({ filepath, problems }: ToDiagnosticItemInput): Diagno
const fromMessageToString = (message: ElmErrorMessage): string =>
typeof message === 'string'
? message
: message.string
: message.string
8 changes: 4 additions & 4 deletions src/features/html-to-elm/src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fromHtmlToElm html =

Err problem ->
Nothing


toElmString : List Html.Parser.Node -> String
toElmString elements =
Expand All @@ -79,8 +79,7 @@ toElmString elements =
|> Elm.Pretty.prettyExpression
in
Pretty.pretty 80 doc




toNodeExpression : Html.Parser.Node -> Maybe Elm.Syntax.Expression.Expression
toNodeExpression node =
Expand Down Expand Up @@ -109,7 +108,8 @@ toNodeExpression node =

Nothing ->
if tagName == "pathmango" then
[ Elm.Syntax.Expression.FunctionOrValue [] ("path") ]
[ Elm.Syntax.Expression.FunctionOrValue [] "path" ]

else if tagName == "main" || tagName == "text" then
[ Elm.Syntax.Expression.FunctionOrValue [] (tagName ++ "_") ]

Expand Down

0 comments on commit edf2ac0

Please sign in to comment.