This repository has been archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch to using prettier-plugin-svelte for formatting (#10)
* switch to using prettier-plugin-svelte for formatting * fallback to prettier html formatting on svelte v2 * update to prettier-plugin-svelte v0.4.1 * update to prettier-plugin-svelte v0.4.2
- Loading branch information
1 parent
644261b
commit 8a5d23c
Showing
9 changed files
with
75 additions
and
139 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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { dirname, resolve } from 'path'; | ||
|
||
export function getSveltePackageInfo(fromPath: string) { | ||
const packageJSONPath = require.resolve('svelte/package.json', { | ||
paths: [fromPath, __dirname], | ||
}); | ||
const { version } = require(packageJSONPath); | ||
const [major, minor, patch] = version.split('.'); | ||
|
||
return { | ||
path: dirname(packageJSONPath), | ||
version: { | ||
full: version, | ||
major, | ||
minor, | ||
patch, | ||
}, | ||
}; | ||
} | ||
|
||
export function importSvelte(fromPath: string) { | ||
const pkg = getSveltePackageInfo(fromPath); | ||
|
||
let main = pkg.path; | ||
if (pkg.version.major > 2) { | ||
main = resolve(pkg.path, 'compiler'); | ||
} | ||
|
||
console.log('Using Svelte v' + pkg.version.full, 'from', main); | ||
|
||
return require(main); | ||
} |
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