Skip to content

Commit 1572ab2

Browse files
committed
provide insight into errors
1 parent 407b13f commit 1572ab2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/cli.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,20 @@ prog.command(`v2 <input>`)
6565

6666
input.forEach((src, i) => {
6767
const dest = output[i];
68-
const upgraded = upgrade.upgradeTemplate(fs.readFileSync(src, 'utf-8'));
6968

70-
mkdirp(path.dirname(dest));
71-
fs.writeFileSync(dest, upgraded);
69+
try {
70+
const upgraded = upgrade.upgradeTemplate(fs.readFileSync(src, 'utf-8'));
71+
72+
mkdirp(path.dirname(dest));
73+
fs.writeFileSync(dest, upgraded);
74+
} catch (err) {
75+
console.error(`${clorox.bold.red(`Error transforming ${src}:`)}`);
76+
console.error(`${clorox.red(err.message)}`);
77+
78+
if (err.frame) {
79+
console.error(err.frame);
80+
}
81+
}
7282
});
7383

7484
console.error(`${clorox.cyan(`Wrote ${output.length} ${output.length === 1 ? 'file' : 'files'}`)}`)

0 commit comments

Comments
 (0)