Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ const yarg = yargs(hideBin(process.argv))
alias: 'silent',
desc: 'Silent output. Do not show "files written" messages',
},
f: {
desc: "Follow symlinks",
type: 'boolean',
alias: 'followSymlinks',
},
})
.alias('h', 'help')
.help('h')
Expand Down Expand Up @@ -86,5 +91,6 @@ async function main(): Promise<void> {
dropExtension: argv.d,
silent: argv.s,
listDifferent: argv.l,
followSymlinks: argv.f,
});
}
9 changes: 7 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface RunOptions {
dropExtension?: boolean;
silent?: boolean;
listDifferent?: boolean;
followSymlinks?: boolean;
}

export async function run(searchDir: string, options: RunOptions = {}): Promise<void> {
Expand Down Expand Up @@ -72,12 +73,16 @@ export async function run(searchDir: string, options: RunOptions = {}): Promise<
}

if (!options.watch) {
const files = await glob(filesPattern);
const files = await glob(filesPattern, {
follow: options.followSymlinks,
});
await Promise.all(files.map(writeFile));
} else {
console.log('Watch ' + filesPattern + '...');

const watcher = chokidar.watch([filesPattern]);
const watcher = chokidar.watch([filesPattern], {
followSymlinks: options.followSymlinks,
});
watcher.on('add', writeFile);
watcher.on('change', writeFile);
watcher.on('unlink', deleteFile);
Expand Down