get tarball name from npm pack

This commit is contained in:
Conduitry 2018-10-04 19:58:05 -04:00
parent 16debee9e8
commit c8f3a52a34
1 changed files with 7 additions and 7 deletions

View File

@ -7,17 +7,17 @@ cd $(git rev-parse --show-toplevel)
# get commit id
ORIG_COMMIT="$(git rev-parse HEAD)"
# extract package name and version from package.json, remove scripts.prepare
# extract version from package.json, and remove scripts.prepare
ORIG_PKG="$(cat package.json)"
read PKG_NAME PKG_VERSION < <(node -e '
PKG_VERSION="$(node -e '
const fs = require("fs");
const pkg = JSON.parse(fs.readFileSync("package.json"));
if (pkg.scripts && pkg.scripts.prepare) {
delete pkg.scripts.prepare;
fs.writeFileSync("package.json", JSON.stringify(pkg, null, "\t") + "\n");
}
console.log(pkg.name + " " + pkg.version);
')
console.log(pkg.version);
')"
# determine current branch name, and create new temporary branch
ORIG_BRANCH=$(git symbolic-ref --short HEAD)
@ -26,9 +26,9 @@ git checkout --orphan=${TEMP_BRANCH}
git rm --cached -rf .
# track the files that should be included in the published package
npm pack
git add -f $(tar tf ${PKG_NAME}-${PKG_VERSION}.tgz | cut -c 9-)
rm ${PKG_NAME}-${PKG_VERSION}.tgz
PKG_TAR="$(npm pack | tail -n 1)"
git add -f $(tar tf ${PKG_TAR} | cut -c 9-)
rm ${PKG_TAR}
# commit and tag
git commit -m "v${PKG_VERSION} @ ${ORIG_COMMIT}"