@yourfam/yf-empty
v0.2.0
Published
Empty file contents and leave the files in place
Readme
yf-empty
Empty file contents and leave the files in place.
Pass a folder to blank every file directly in it, or a folder and file names to blank only those. Tracked files and gitignored files are both fine. The tool does not commit. Node 20+.
- Source / README: https://github.com/YourFam/yf-empty
- npm: https://www.npmjs.com/package/@yourfam/yf-empty
- Unscoped alias: https://www.npmjs.com/package/yf-git-empty
- Issues: https://github.com/YourFam/yf-empty/issues
Install
npm install -g @yourfam/yf-emptyThen from any directory:
yf-empty path/to/folderThe command is yf-empty. No install:
npx @yourfam/yf-empty path/to/folder
npx yf-git-empty path/to/foldernpx yf-git-empty is the unscoped alias of @yourfam/yf-empty (same CLI, same version). npm may reject unscoped yf-empty as too similar to an existing package. After -g, the command is yf-empty.
| | npm install -g @yourfam/yf-empty | npm install -D @yourfam/yf-empty |
|---|---|---|
| Where it goes | Global npm prefix | node_modules/ of the current repo |
| Command | yf-empty from any folder | npx yf-empty in that repo |
| Typical use | A CLI you want everywhere | A tool this repo runs in scripts |
With -D, plain yf-empty is not on your PATH. Use npx yf-empty.
Usage
yf-empty <folder> [file...]
yf-empty --y <folder> [file...]
yf-empty --this-folderyf-empty notes
yf-empty notes a.txt b.txt
yf-empty notes draft/a.txt
yf-empty --this-folder
yf-empty --y notesThe command warns before it changes anything:
Destructive: this will empty the files in notes.
Press Y to continue:With file names, the warning names those files. Type Y and press Enter. Any other answer leaves every file as it is.
--y skips that prompt. You already approved the empty, so the command runs. A script or a non-interactive shell has no prompt to answer: pass --y, or the command refuses and changes nothing.
A folder alone empties every file sitting directly in that folder. Files in subfolders stay as they are. Dotfiles in that folder are included.
File names are relative to the folder. Only those files are emptied. ../secret.txt is refused. A missing name fails the command before any file is changed.
Symlinks are refused, so a shortcut is not followed into another file. Directories are not removed. Git is not read and not changed. If the empty files should be recorded, commit them yourself.
--this-folder empties the files in the directory where you run the command. It does not take a folder name. yf-empty with no arguments prints an error instead of blanking the current directory.
Each emptied file is printed to stderr as emptied a.txt. An empty folder prints emptied 0 files.
Development
git clone https://github.com/YourFam/yf-empty.git
cd yf-empty
npm test
node ./bin/yf-empty.js --helpMaintainer: YourFam (kamal-yourfam on npm). MIT.
Publish the unscoped alias (maintainers)
The GitHub repo publishes two npm packages at the same version:
npm publish --access publicfrom the repo root →@yourfam/yf-empty- Then from
alias/, with matchingversionanddependencies["@yourfam/yf-empty"]:
cd alias
npm publish --access publicThat second package is named yf-git-empty and only shims the scoped CLI so npx yf-git-empty cannot be squatted.
License
MIT © 2026 YourFam. See LICENSE.
