Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
LorisSigrist committed Oct 12, 2023
1 parent 4d7dfcb commit 6d91535
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
8 changes: 4 additions & 4 deletions src/core/file-handling/fileHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class FileHandler {
const handler = this.#getHandler(filePath);
if (!handler)
throw new LoadingException(
`Could not find handler for ${filePath}. Supported file extensions are ${this.getSupportedFileExtensions()}`
`Could not find handler for ${filePath}. Supported file extensions are ${this.getSupportedFileExtensions()}`,
);
const textContent = await this.#readFileContent(filePath);
const keyVal = handler.load(filePath, textContent);
Expand All @@ -40,7 +40,7 @@ export class FileHandler {
const handler = this.#getHandler(filePath);
if (!handler)
throw new LoadingException(
`Could not find handler for ${filePath}. Supported file extensions are ${this.getSupportedFileExtensions()}`
`Could not find handler for ${filePath}. Supported file extensions are ${this.getSupportedFileExtensions()}`,
);

const textContent = await this.#readFileContent(filePath);
Expand All @@ -58,11 +58,11 @@ export class FileHandler {
const fileExtension = filename.split(".").at(-1);
if (typeof fileExtension !== "string")
throw new LoadingException(
"Could not determine file extension for ${filePath}"
"Could not determine file extension for ${filePath}",
);

const handler = this.#handlers.find((l) =>
l.fileExtensions.includes(fileExtension)
l.fileExtensions.includes(fileExtension),
);

return handler ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/core/file-handling/formats/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function parseAsTree(content, filePath = undefined) {
console.warn("Raising loading exception");
throw new LoadingException(
`Could not parse JSON file ${filePath ?? ""}: ${e.message}`,
{ cause: e }
{ cause: e },
);
};

Expand Down
7 changes: 3 additions & 4 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export function t18sCore(pluginConfig) {
})
.run();


const { dictionary, invalidKeys } = compileToDictionary(keyVal, locale);

if (invalidKeys) reporter.warnAboutInvalidKeys(filePath, invalidKeys);
Expand Down Expand Up @@ -202,7 +201,7 @@ export function t18sCore(pluginConfig) {
});
} else {
logger.error(
`Could not trigger HMR event '${event}' for locale '${locale}' because the viteDevServer is not available. This should never happen.`
`Could not trigger HMR event '${event}' for locale '${locale}' because the viteDevServer is not available. This should never happen.`,
);
}
}
Expand All @@ -216,7 +215,7 @@ export function t18sCore(pluginConfig) {
dtsPath: resolve(resolvedConfig.root, pluginConfig.dts),
translationsDir: resolve(
resolvedConfig.root,
pluginConfig.translationsDir
pluginConfig.translationsDir,
),
verbose: pluginConfig.verbose,
};
Expand All @@ -231,7 +230,7 @@ export function t18sCore(pluginConfig) {
if (id.startsWith(VIRTUAL_MODULE_PREFIX)) {
return id.replace(
VIRTUAL_MODULE_PREFIX,
RESOLVED_VIRTUAL_MODULE_PREFIX
RESOLVED_VIRTUAL_MODULE_PREFIX,
);
}
},
Expand Down
39 changes: 19 additions & 20 deletions src/core/utils/bufferPromise.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
/**
* Await a promise and save the result & errors so that they can be synchronously replayed later.
*
*
* @template {any} T
* @param {T} promise
*
* @param {T} promise
*
* @returns {Promise<()=> Awaited<T>>}
*/
export async function buffer(promise) {
/** @type {Awaited<T>} */
let resolvedWith;
/** @type {Awaited<T>} */
let resolvedWith;

/** @type {unknown} */
let rejectedWith;
let rejected = false;
/** @type {unknown} */
let rejectedWith;
let rejected = false;

try {
resolvedWith = await promise;
} catch (e) {
rejectedWith = e;
rejected = true;
}

try {
resolvedWith = await promise;
} catch (e) {
rejectedWith = e;
rejected = true;
}

return () => {
if (rejected) throw rejectedWith;
return resolvedWith;
}
}
return () => {
if (rejected) throw rejectedWith;
return resolvedWith;
};
}

0 comments on commit 6d91535

Please sign in to comment.