This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Add Windows support #35
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 +7,7 @@ const { LanguageClient } = require('vscode-languageclient'); | |
class CommandNotFoundError extends Error {} | ||
class IncompatibleVersionError extends Error {} | ||
|
||
const isWin = process.platform === 'win32'; | ||
const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); | ||
|
||
let client; | ||
|
@@ -47,7 +48,7 @@ async function startServer() { | |
}; | ||
|
||
client = new LanguageClient( | ||
'theme-check', | ||
'shopifyLiquid', | ||
'Theme Check Language Server', | ||
serverOptions, | ||
clientOptions, | ||
|
@@ -56,7 +57,6 @@ async function startServer() { | |
client.start(); | ||
} | ||
|
||
|
||
async function stopServer() { | ||
try { | ||
if (client) await Promise.race([client.stop(), sleep(1000)]); | ||
|
@@ -71,7 +71,6 @@ async function restartServer() { | |
if (client) await stopServer(); | ||
await startServer(); | ||
} | ||
/** */ | ||
|
||
function onConfigChange(event) { | ||
const didChangeThemeCheck = event.affectsConfiguration( | ||
|
@@ -118,21 +117,25 @@ async function getServerOptions() { | |
} | ||
} | ||
|
||
async function which(command) { | ||
const whichCmd = isWin ? 'where' : 'which'; | ||
const { stdout } = await exec(`${whichCmd} ${command}`); | ||
return stdout.split('\n')[0].replace('\r', ''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 |
||
} | ||
|
||
async function getShopifyCLIExecutable() { | ||
try { | ||
const { stdout } = await exec('which shopify'); | ||
return shopifyCLIExecutable(stdout.replace('\n', '')); | ||
const path = await which('shopify'); | ||
return shopifyCLIExecutable(path); | ||
} catch (e) { | ||
return undefined; | ||
} | ||
} | ||
|
||
async function getThemeCheckExecutable() { | ||
try { | ||
const { stdout } = await exec( | ||
'which theme-check-language-server', | ||
); | ||
return themeCheckExecutable(stdout.replace('\n', '')); | ||
const path = await which('theme-check-language-server'); | ||
return themeCheckExecutable(path); | ||
} catch (e) { | ||
return undefined; | ||
} | ||
|
@@ -173,7 +176,7 @@ async function shopifyCLIIsAtLeastVersion2(command) { | |
|
||
async function themeCheckExecutableExists(command) { | ||
try { | ||
await exec(`[[ -f "${command}" ]]`); | ||
!isWin && (await exec(`[[ -f "${command}" ]]`)); | ||
} catch (e) { | ||
throw new CommandNotFoundError( | ||
`${command} not found, are you sure this is the correct path?`, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the configuration. This way you can set
In your VS Code settings.json and see the lsp logs in the Output pane. Leaving it as theme-check meant that it had to be "theme-check.server.logs" which feels out of place with the rest of the configuration options.