-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from lydell/update-elm-format
Update to elm-format 0.8.7 and support installation in Fish shell
- Loading branch information
Showing
4 changed files
with
23 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
}) | ||
) | ||
|
@@ -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_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
}) | ||
) | ||
|
@@ -411,4 +411,4 @@ const toDiagnosticItem = ({ filepath, problems }: ToDiagnosticItemInput): Diagno | |
const fromMessageToString = (message: ElmErrorMessage): string => | ||
typeof message === 'string' | ||
? message | ||
: message.string | ||
: message.string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters