From b56407edd65559c88501f539479a6c6e2698d767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Mon, 23 Dec 2019 11:24:25 +0100 Subject: [PATCH] fix(cli): fix "--out-dir" with single svg Closes #304 --- packages/cli/src/dirCommand.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/dirCommand.js b/packages/cli/src/dirCommand.js index 6f566b59..77d8aa58 100644 --- a/packages/cli/src/dirCommand.js +++ b/packages/cli/src/dirCommand.js @@ -69,7 +69,7 @@ export default async function dirCommand( async function handle(filename, root) { const stats = await stat(filename) - if (stats.isDirectory(filename)) { + if (stats.isDirectory()) { const dirname = filename const files = await readdir(dirname) const results = await Promise.all( @@ -90,5 +90,11 @@ export default async function dirCommand( return write(filename, dest) } - await Promise.all(filenames.map(file => handle(file, file))) + await Promise.all( + filenames.map(async file => { + const stats = await stat(file) + const root = stats.isDirectory() ? file : path.dirname(file) + return handle(file, root) + }), + ) }