diff --git a/src/cli.ts b/src/cli.ts index 96c9fed..8cdb1f8 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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') @@ -86,5 +91,6 @@ async function main(): Promise { dropExtension: argv.d, silent: argv.s, listDifferent: argv.l, + followSymlinks: argv.f, }); } diff --git a/src/run.ts b/src/run.ts index bea8ff1..c2e004c 100644 --- a/src/run.ts +++ b/src/run.ts @@ -13,6 +13,7 @@ interface RunOptions { dropExtension?: boolean; silent?: boolean; listDifferent?: boolean; + followSymlinks?: boolean; } export async function run(searchDir: string, options: RunOptions = {}): Promise { @@ -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);