Skip to content

Commit

Permalink
fix(env): add os.plaform() polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jul 28, 2020
1 parent be4f16d commit 93b53e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/compiler/sys/modules/os.ts
@@ -1,5 +1,10 @@
import { OS_PLATFORM } from '@utils';

export const EOL = '\n';

export const platform = () => (OS_PLATFORM === 'windows' ? 'win32' : OS_PLATFORM);

export default {
EOL,
platform,
};
2 changes: 2 additions & 0 deletions src/utils/environment.ts
Expand Up @@ -10,6 +10,8 @@ export const IS_NODE_ENV =
typeof __filename === 'string' &&
(!((global as any) as Window).origin || typeof ((global as any) as Window).origin !== 'string');

export const OS_PLATFORM = IS_NODE_ENV ? global.process.platform : IS_DENO_ENV ? (globalThis as any).Deno.build.os : '';

export const IS_DENO_WINDOWS_ENV = IS_DENO_ENV && Deno.build.os === 'windows';

export const IS_NODE_WINDOWS_ENV = IS_NODE_ENV && global.process.platform === 'win32';
Expand Down

0 comments on commit 93b53e2

Please sign in to comment.