Skip to content

Commit

Permalink
feat(scripts): add npm package checker script
Browse files Browse the repository at this point in the history
  • Loading branch information
Alnyli07 committed Jan 23, 2024
1 parent 8f75b32 commit bc4eff4
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 4 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"watch": "rm -rf dist && tsc -w",
"build": "rm -rf dist && tsc",
"postversion": "git push && git push --tags",
"postuninstall": "node ./scripts/appcircle-uninstall.js"
"postuninstall": "node ./scripts/appcircle-uninstall.js",
"check:package": "zx ./scripts/check-package.mjs"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -53,6 +54,7 @@
"@types/jsonfile": "^6.0.0",
"@types/minimist": "^1.2.1",
"@types/node": "^15.12.5",
"typescript": "^4.3.4"
"typescript": "^4.3.4",
"zx": "^7.2.3"
}
}
11 changes: 11 additions & 0 deletions scripts/check-package.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env zx

const packageJson = require("../package.json");
const npmPackageInfo = JSON.parse((await $`npm view ${packageJson.name} --json`).stdout);
if (npmPackageInfo.versions.includes(packageJson.version)) {
console.log(`${packageJson.version} version already published!`);
process.exit(1);
} else {
console.log(`${packageJson.version} version is available, not previously published.`);
process.exit(0);
}
Loading

0 comments on commit bc4eff4

Please sign in to comment.