Skip to content

Commit 3a6582c

Browse files
committed
refactor(cli): always use same options when writing JSON
1 parent 0abfb7b commit 3a6582c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/cli/bin/utils.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,23 @@ const checkAndInstallPackage = (packageName, url) =>
175175
*/
176176
const noop = () => {};
177177

178+
/**
179+
* @func writeJsonAsync
180+
* Wrapper for fs.writeJsonAsync with consistent spacing
181+
* @param {string} filePath
182+
* @param {object} data
183+
*/
184+
const writeJsonAsync = (filePath, data) =>
185+
wrapAsync(function*() {
186+
yield fs.outputJSON(filePath, data, { spaces: 2 });
187+
});
188+
178189
module.exports = {
179190
copyWithPattern,
180191
copyAsync: fs.copy,
181192
mkdirsAsync: fs.mkdirs,
182193
moveAsync: fs.move,
183-
writeJsonAsync: fs.outputJson,
194+
writeJsonAsync: writeJsonAsync,
184195
readJsonAsync: fs.readJson,
185196
error,
186197
info,

0 commit comments

Comments
 (0)