Skip to content

Commit

Permalink
Add error-handling to WillFarrell\AlfredPkgMan\Npm
Browse files Browse the repository at this point in the history
* Deal w/ an optional attribute for NPM modules
* Disable error reporting
    - PHP will echo warning & error messages by default, so in order to
avoid polluting what Alfred processes, we disable reporting

Fixes #165
  • Loading branch information
jeffbyrnes committed Aug 7, 2022
1 parent 1113389 commit 4ee62b5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Npm.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
namespace WillFarrell\AlfredPkgMan;

// README: Turn off all error reporting
// Comment this out to enable error reporting for debugging
error_reporting(0);

class Npm extends Repo
{
Expand All @@ -20,10 +23,17 @@ public function search($query)
$query,
"{$this->search_url}{$query}&size={$this->max_return}"
);

foreach ($this->pkgs->results as $pkg) {
$p = $pkg->package;
$p = $pkg->package;
$name = $p->name;
$uid = "{$this->id}-{$name}-{$p->version}";
$uid = "{$this->id}-{$name}-{$p->version}";

// README: Description is not required to publish a module, so we check for it
// and fall back to an empty string if it is missing
$p->description
? $description = $p->description
: $description = '';

$this->cache->w->result(
$uid,
Expand Down

0 comments on commit 4ee62b5

Please sign in to comment.