Skip to content

Commit 820be08

Browse files
committed
Fix glob and prettier plugin bugs
- The glob library returns paths relative to the root directory you pass it, not the process cwd. Set `absolute` so that we get read the right XLB paths. - Explicitly tell Prettier to resolve the XML plugin. While it was working fine from _this_ repo, when lit-localize was installed in another package, the plugin was not being automatically loaded. Not sure why exactly that is, maybe it auto-loads @prettier plugins only in some node_modules/ layouts.
1 parent b873cf7 commit 820be08

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
<!-- ## Unreleased -->
8+
## Unreleased
9+
10+
- Fix incorrect path resolution when loading XLB files.
11+
- Fix errors relating to prettier xml plugin resolution.
912

1013
## [0.2.1] - 2020-05-13
1114

src/formatters/xlb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class XlbFormatter implements Formatter {
7979
const files = await new Promise<string[]>((resolve, reject) =>
8080
glob(
8181
this.xlbConfig.translationsGlob,
82-
{cwd: this.config.baseDir},
82+
{cwd: this.config.baseDir, absolute: true},
8383
(err, files) => {
8484
if (err) {
8585
reject(err);

src/formatters/xml-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function getNonEmptyAttributeOrThrow(
5353
export function formatXml(xmlStr: string): string {
5454
// TODO(aomarks) Types for the xml-parser plugin.
5555
return prettier.format(xmlStr, ({
56+
plugins: ['@prettier/plugin-xml'],
5657
parser: 'xml',
5758
xmlWhitespaceSensitivity: 'ignore',
5859
} as unknown) as prettier.Options);

0 commit comments

Comments
 (0)