-s tests existence and size > 0.
if [[ -s dist/index.html ]]; then echo ok; fi bashbasics
All tips
- Bash: check a file is non-empty bashbasics
- Bash: check command success with `|| exit` bashscripts
- Bash: check environment variables bashbasics
- Bash: check if a command exists bashscripts
- Bash: create a directory if missing bashbasics
- Bash: create a timestamp string bashbasics
- Bash: default a variable bashbasics
- Bash: exit with a message bashscripts
- Bash: fail fast in scripts bashscripts
- Bash: find files by extension bashworkflow
- Bash: iterate over args safely bashscripts
- Bash: loop over lines safely bashpitfalls
- Bash: pipe output to both console and file bashworkflow
- Bash: print script directory bashscripts
- Bash: quote variables to avoid word-splitting bashpitfalls
- Bash: readable multi-line commands bashstyle
- Bash: run a command in a directory bashworkflow
- Bash: run a command only if a file exists bashscripts
- Bash: safer rm with `--` bashpitfalls
- Bash: show last command exit code bashbasics
- Bash: trap cleanup on exit bashscripts
- Bash: use `[[ ... ]]` for safer tests bashbasics
- Bash: use `printf` over `echo -e` bashbasics
- Bash: use arrays for arguments bashscripts
- Bash: use here-strings for quick input bashbasics
- CSS: center a div (flexbox) csslayout
- How to reverse a list in Python pythonbasics
- pnpm: add a dependency pnpmworkflow
- pnpm: add a dev dependency pnpmworkflow
- pnpm: add a package at a specific version pnpmworkflow
- pnpm: add scripts for repeatable tasks pnpmworkflow
- pnpm: check outdated packages pnpmworkflow
- pnpm: check why a package is installed pnpmtroubleshooting
- pnpm: clean install from lockfile pnpmci
- pnpm: enable corepack (optional) pnpmworkflow
- pnpm: install only production deps pnpmci
- pnpm: keep scripts deterministic in CI pnpmci
- pnpm: list top-level deps pnpmworkflow
- pnpm: lockfile is the source of truth pnpmconcepts
- pnpm: prefer `pnpm dlx` for `create-*` pnpmworkflow
- pnpm: recreate node_modules pnpmtroubleshooting
- pnpm: remove a package pnpmworkflow
- pnpm: run a binary from node_modules pnpmbasics
- pnpm: run a script pnpmbasics
- pnpm: set Node version expectations pnpmworkflow
- pnpm: speed up repeated installs pnpmperformance
- pnpm: troubleshooting ignored build scripts pnpmtroubleshooting
- pnpm: update a single package pnpmworkflow
- pnpm: update dependencies pnpmworkflow
- pnpm: use `--filter` for targeted workspace runs pnpmworkspaces
- pnpm: use `pnpm -r` in workspaces pnpmworkspaces
- pnpm: use `pnpm dlx` for one-off CLIs pnpmworkflow
- pnpm: use workspace protocols (monorepos) pnpmworkspaces
- pnpm: why node_modules is smaller pnpmconcepts
- Python: `defaultdict` for grouped data pythonstdlib
- Python: `json.dumps(..., indent=2)` for readable JSON pythonstdlib
- Python: `match` for structured branching (3.10+) pythonpatterns
- Python: `python -m venv .venv` quick env creation pythonworkflow
- Python: `str.removeprefix` / `removesuffix` pythonbasics
- Python: `zip` to iterate in parallel pythonbasics
- Python: avoid mutable default args pythonpitfalls
- Python: context managers for cleanup pythonpatterns
- Python: dataclasses for simple models pythonpatterns
- Python: f-strings for readable formatting pythonbasics
- Python: generator expressions for streaming pythonperformance
- Python: join strings (don’t use + in loops) pythonperformance
- Python: list comprehensions for transforms pythonbasics
- Python: merge dicts with | (3.9+) pythonbasics
- Python: pathlib beats os.path pythonfilesystem
- Python: quick dict get with default pythonbasics
- Python: reverse a list safely pythonbasics
- Python: shallow copy a list pythonbasics
- Python: sorting with key functions pythonbasics
- Python: type hints help maintenance pythontyping
- Python: unpack iterables with * pythonbasics
- Python: use `any()` / `all()` for predicates pythonpatterns
- Python: use `collections.Counter` for frequencies pythonstdlib
- Python: use enumerate for index + value pythonpatterns
- TypeScript: `as const` for route maps typescriptpatterns
- TypeScript: `Intl.NumberFormat` for currency typescriptweb
- TypeScript: `Map` for non-string keys typescriptbasics
- TypeScript: `never` for exhaustive checks typescripttyping
- TypeScript: `Promise.allSettled` for best-effort batches typescriptpatterns
- TypeScript: `readonly` props reduce accidental mutation typescriptstyle
- TypeScript: avoid floating promises typescriptpitfalls
- TypeScript: const assertions for literal types typescripttyping
- TypeScript: infer with `Parameters` typescripttyping
- TypeScript: infer with `ReturnType` typescripttyping
- TypeScript: make unions discriminated typescripttyping
- TypeScript: narrow with `in` operator typescripttyping
- TypeScript: nullish coalescing vs OR typescriptpitfalls
- TypeScript: optional chaining reduces guard noise typescriptpatterns
- TypeScript: prefer `interface` for public object shapes typescriptstyle
- TypeScript: prefer `Record` for simple maps typescriptbasics
- TypeScript: prefer `unknown` over `any` typescripttyping
- TypeScript: sort numbers correctly typescriptpitfalls
- TypeScript: stable JSON parsing helper typescriptpatterns
- TypeScript: type a tuple return value typescripttyping
- TypeScript: type predicates for custom guards typescripttyping
- TypeScript: use `AbortController` for cancellable fetch typescriptweb
- TypeScript: use `readonly` arrays for safety typescripttyping
- TypeScript: use `satisfies` for safer configs typescripttyping