1
0
Fork 0

nicer package.json formatting

This commit is contained in:
Conduitry 2018-12-08 19:59:06 -05:00
parent b0695b7c6b
commit 3c1dc99d61
1 changed files with 5 additions and 2 deletions

View File

@ -10,9 +10,12 @@ ORIG_COMMIT="$(git rev-parse HEAD)"
cp package.json package.json.bak
PKG_VERSION="$(node -e '
const fs = require("fs");
const pkg = JSON.parse(fs.readFileSync("package.json"));
const str = fs.readFileSync("package.json").toString();
const m = str.match(/\n([\t ]+)/);
const indent = m ? m[1] : "\t";
const pkg = JSON.parse(str);
pkg.scripts && delete pkg.scripts.prepare;
fs.writeFileSync("package.json", JSON.stringify(pkg));
fs.writeFileSync("package.json", JSON.stringify(pkg, null, indent) + (str.endsWith("\n") ? "\n" : ""));
console.log(pkg.version);
')"