-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
6 changed files
with
76 additions
and
26 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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
} | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
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 |
---|---|---|
@@ -1 +1,45 @@ | ||
// NOTE this fixes metro not logging correctly for some reason | ||
if (__DEV__) { | ||
const primitiveTypes = ['string', 'number', 'boolean']; | ||
const logLevels = ['log', 'debug', 'info', 'warn', 'error']; | ||
|
||
const transformArgs = (args) => { | ||
return args.map((arg) => { | ||
if (arg === undefined) { | ||
return 'undefined'; | ||
} | ||
if (arg instanceof Error) { | ||
if (arg.stack) { | ||
return arg.stack; | ||
} | ||
return arg.toString(); | ||
} | ||
if (arg instanceof Date) { | ||
return arg.toString(); | ||
} | ||
if (primitiveTypes.includes(typeof arg)) { | ||
return arg.toString(); | ||
} else { | ||
return JSON.stringify(arg); | ||
} | ||
}); | ||
}; | ||
|
||
const consoleProxy = new Proxy(console, { | ||
get: (target, prop) => { | ||
//@ts-ignore | ||
if (logLevels.includes(prop)) { | ||
return (...args) => { | ||
// we proxy the call to itself, but we transform the arguments to strings before | ||
// so that they are printed in the terminal | ||
return target[prop].apply(this, transformArgs(args)); | ||
}; | ||
} | ||
return target[prop]; | ||
}, | ||
}); | ||
|
||
console = consoleProxy; | ||
} | ||
|
||
export { default } from './.storybook'; |
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
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