Skip to content

Commit

Permalink
fix: verify cargo search returns results
Browse files Browse the repository at this point in the history
If the crate has never been published and cargo search returns nothing
we should return false
  • Loading branch information
diogomatsubara committed Aug 6, 2024
1 parent dbbc45b commit 289db8e
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 9 deletions.
6 changes: 5 additions & 1 deletion dist/build-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127543,7 +127543,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion dist/build-crates-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127527,7 +127527,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion dist/bump-crates-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -81249,7 +81249,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -81137,7 +81137,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = (0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = (0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127522,7 +127522,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion dist/publish-crates-eclipse-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127603,7 +127603,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127603,7 +127603,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion dist/publish-crates-homebrew-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127507,7 +127507,11 @@ function toDebianVersion(version, revision) {
*/
function isPublished(pkg) {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

Expand Down
6 changes: 5 additions & 1 deletion src/cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ export function toDebianVersion(version: string, revision?: number): string {
*/
export function isPublished(pkg: Package): boolean {
// Hackish but crates.io doesn't have a stable api anyway.
const publishedVersion = sh(`cargo search ${pkg.name}`).split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
const results = sh(`cargo search ${pkg.name}`);
if (!results) {
return false;
}
const publishedVersion = results.split("\n").at(0).match(/".*"/g).at(0).slice(1, -1);
return publishedVersion === pkg.version;
}

0 comments on commit 289db8e

Please sign in to comment.