generated from acttoreact/ts-node-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
51 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ yarn-error.log* | |
|
||
# Compiled version | ||
dist/ | ||
bin/ | ||
|
||
# Runtime data | ||
pids | ||
|
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"tslib" | ||
], | ||
"search.exclude": { | ||
"**/bin": true, | ||
"**/node_modules": true, | ||
"**/docs/jsdocs": true | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import path from 'path'; | ||
|
||
import { readFile } from '../../../tools/fs'; | ||
import getIsClientContent from '../../../utils/getIsClientContent'; | ||
|
||
const isClientPath = path.resolve(__dirname, '../../../tools/isClient.ts'); | ||
|
||
/** | ||
* isClient content should be the same as `isClient.ts` file | ||
*/ | ||
test('isClient content', async (): Promise<void> => { | ||
const fileContent = await readFile(isClientPath, 'utf8'); | ||
expect(getIsClientContent()).toBe(fileContent); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const getIsClientContent = (): string => `let forceServerSimulation = false; | ||
/** | ||
* Allows you to disable client detection | ||
* @param {boolean} value True to force Server Side Simulation | ||
*/ | ||
export const setForceServerSimulation = (value: boolean): void => { | ||
forceServerSimulation = value; | ||
}; | ||
/** | ||
* Checks if the script is running on the client side | ||
*/ | ||
const isClient = (): boolean => { | ||
if (forceServerSimulation) { | ||
return false; | ||
} | ||
return typeof window === 'object'; | ||
}; | ||
export default isClient;` | ||
|
||
export default getIsClientContent; |
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