Fail but still generate manifest

This commit is contained in:
Michael Rose 2020-03-07 18:27:35 -05:00
parent 39bbadec7c
commit 36884f01a9
2 changed files with 5 additions and 12 deletions

View file

@ -34,7 +34,7 @@ While you can install `packwatch` as a global package, it's better to include it
## Usage
`packwatch` tracks your packages' size via its `.packwatch.json` manifest. To get started, call `packwatch --update-manifest` at the root of your project: a fresh manifest will be generated for you using your current package's size as the initial upper limit for package size.
`packwatch` tracks your packages' size via its `.packwatch.json` manifest. To get started, call `packwatch` at the root of your project: a fresh manifest will be generated for you using your current package's size as the initial upper limit for package size.
Once a manifest file exists, calling `packwatch` again will compare its data to the current state of your package. Every time `packwatch` compares your code to the manifest, it will update the last reported package size statistics it contains, but not the limit you have set.

View file

@ -16,9 +16,7 @@ if (!existsSync('package.json')) {
process.exit(1)
}
const UPDATE_MANIFEST_OPTION = '--update-manifest'
const isUpdatingManifest = process.argv.includes(UPDATE_MANIFEST_OPTION)
const isUpdatingManifest = process.argv.includes('--update-manifest')
const currentStats = getCurrentPackageStats()
@ -28,13 +26,6 @@ const currentStats = getCurrentPackageStats()
*/
if (!existsSync(MANIFEST_FILENAME)) {
if (!isUpdatingManifest) {
console.log(
`🔥🔥📦🔥🔥 No manifest file exists! Run packwatch with ${UPDATE_MANIFEST_OPTION} to generate a manifest file`,
)
process.exit(1)
}
createOrUpdateManifest({ current: currentStats })
console.log(
`📝 No Manifest to compare against! Current package stats written to ${MANIFEST_FILENAME}!`,
@ -42,7 +33,9 @@ if (!existsSync(MANIFEST_FILENAME)) {
console.log(
`Package size (${currentStats.packageSize}) adopted as new limit.`,
)
process.exit(0)
// If the update flag wasn't specified, exit with a non-zero code so we
// don't "accidentally" pass CI builds if the manifest didn't exist
process.exit(isUpdatingManifest ? 0 : 1)
}
const previousStats = getPreviousPackageStats()