Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ts/util/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
*/

declare const process: { platform: string };
declare const exports: object;

/**
* True if there is a window object
*/
export const hasWindow = typeof window !== 'undefined';

/**
* True if used from the cjs directory, false for mjs directory
*/
export const isCJS = typeof exports !== 'undefined';

/**
* The browsers window and document objects, if any
*/
Expand Down Expand Up @@ -75,6 +81,6 @@ export const context = {
if (context.os === 'Windows') {
context.path = (file: string) =>
file.match(/^[/\\]?[a-zA-Z]:[/\\]/)
? 'file://' + file.replace(/\\/g, '/').replace(/^\//, '')
? (isCJS ? '' : 'file://') + file.replace(/\\/g, '/').replace(/^\//, '')
: file.replace(/^\//, 'file:///');
}
Loading