git ls-files | grep -E '.(ts|tsx|js|jsx)$' | xargs wc --lines
output:
$ git ls-files | grep -e '.ts$' -e '.tsx$' | xargs wc --lines
#!/bin/bash | |
# Install VS Code extensions | |
# if need to use powershell: https://gist.github.com/vmandic/ef80f1097521c16063b3b1c3a687d244 | |
# `code --install-extension` will echo | |
# echo Installing VS Code Extensions... | |
extensions=( | |
dsznajder.es7-react-js-snippets |
$nodeVersion = node -v | |
Write-Host "Node.js Version: $nodeVersion" | |
if ($nodeVersion -eq $null) { | |
Write-Host "Node.js is not installed." | |
exit 1 | |
} | |
$npmVersion = npm -v | |
Write-Host "npm Version: $npmVersion" | |
if ($npmVersion -eq $null) { |
Mocking .env variables in isolation during Jest tests can be useful to test different scenarios without changing the actual .env file. This is helpful for functions that read from the .env file especially in a different scope or context.
getFilePath.ts
export const getFilePath = () => process.env.FILE_PATH;
#!/bin/bash | |
tree=$(tree -tf --noreport -I '*~' --charset ascii $1 | | |
sed -e 's/| \+/ /g' -e 's/[|`]-\+/ */g' -e 's:\(* \)\(\(.*/\)\([^/]\+\)\):\1[\4](\2):g') | |
printf "# Project tree\n\n${tree}" |
const parseByContentType = async <T = unknown>(data: Response): Promise<T> => { | |
const contentType = data.headers.get('Content-Type'); | |
if (contentType === null) { | |
console.log('contentType is null'); | |
return (await data.text()) as T; | |
} else if (contentType.includes('application/json')) { | |
return (await data.json()) as T; | |
} else if (contentType.includes('text')) { | |
return (await data.text()) as T; |