From a1e0636c485222db3f2c7b917964134b5f53b560 Mon Sep 17 00:00:00 2001 From: Aolin Date: Mon, 8 Aug 2022 11:09:54 +0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Ran --- src/replaceint.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/replaceint.js b/src/replaceint.js index 431f743..7720eaa 100644 --- a/src/replaceint.js +++ b/src/replaceint.js @@ -6,10 +6,10 @@ function replaceIntegerInternal(obj) { replaceIntegerInternal(obj[item]); } else if (item == "type" && obj[item] === "integer") { - if (obj["example"] != undefined && typeof (obj["example"]) != "number") { + if (obj["example"] != undefined && typeof obj["example"] != "number") { obj["example"] = parseInt(obj["example"]); } - if (obj["default"] != undefined && typeof (obj["default"]) != "number") { + if (obj["default"] != undefined && typeof obj["default"] != "number") { obj["default"] = parseInt(obj["default"]); } } @@ -22,7 +22,7 @@ async function replaceInteger(readf, writef) { const data = JSON.parse(fs.readFileSync(readf, 'utf8')); const schema = replaceIntegerInternal(data); fs.writeFileSync(writef, JSON.stringify(schema, null, 2)); - + console.log(`Replace wrong string with int in ${writef}`); } module.exports = replaceInteger;