Skip to content

Commit

Permalink
Require Node.js 14
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 9, 2022
1 parent 93b4d2b commit ced041d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
21 changes: 10 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
'use strict';
const alfy = require('alfy');
const cmdSubtitle = require('./source/cmd-subtitle');
import alfy from 'alfy';
import cmdSubtitle from './source/cmd-subtitle.js';

// Do not boost exact matches by default, unless specified by the input
const q = /boost-exact:[^\s]+/.test(alfy.input) ? alfy.input : `${alfy.input} boost-exact:false`;
const q = /boost-exact:\S+/.test(alfy.input) ? alfy.input : `${alfy.input} boost-exact:false`;

const data = await alfy.fetch('https://api.npms.io/v2/search', {
query: {
q,
size: 20
}
size: 20,
},
});

const items = data.results
Expand All @@ -24,17 +23,17 @@ const items = data.results
mods: {
alt: {
arg: pkg.links.npm,
subtitle: 'Open the npm page instead of the GitHub repo'
subtitle: 'Open the npm page instead of the GitHub repo',
},
cmd: {
subtitle: cmdSubtitle(pkg)
subtitle: cmdSubtitle(pkg),
},
ctrl: {
arg: pkg.name,
subtitle: 'Copy package name'
}
subtitle: 'Copy package name',
},
},
quicklookurl: pkg.links.repository && `${pkg.links.repository}#readme`
quicklookurl: pkg.links.repository && `${pkg.links.repository}#readme`,
};
});

Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"description": "Alfred workflow to search for npm packages with npms.io",
"license": "MIT",
"repository": "sindresorhus/alfred-npms",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=14.13.1"
},
"scripts": {
"test": "xo && ava",
Expand All @@ -33,13 +36,13 @@
"alfy"
],
"dependencies": {
"alfy": "^0.8.0",
"date-format": "^2.0.0"
"alfy": "^0.12.2",
"date-format": "^3.0.0"
},
"devDependencies": {
"alfy-test": "^0.3.0",
"ava": "^1.0.1",
"semver-regex": "^2.0.0",
"xo": "^0.23.0"
"alfy-test": "^0.4.2",
"ava": "^4.0.1",
"semver-regex": "^4.0.2",
"xo": "^0.47.0"
}
}
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ npms.io is a great npm package search with deep analysis of package quality usin

## Install

```
$ npm install --global alfred-npms
```sh
npm install --global alfred-npms
```

*Requires [Node.js](https://nodejs.org) 8+ and the Alfred [Powerpack](https://www.alfredapp.com/powerpack/).*
*Requires [Node.js](https://nodejs.org) 14+ and the Alfred [Powerpack](https://www.alfredapp.com/powerpack/).*

## Usage

Expand Down
7 changes: 3 additions & 4 deletions source/cmd-subtitle.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use strict';
const dateFormat = require('date-format');
import dateFormat from 'date-format';

/**
@param {object} pkg - A single package from the npms API.
@returns {string} The command-modifier subtitle for the package.
*/
module.exports = ({author, date, publisher, version}) => {
export default function cmdSubtitle({author, date, publisher, version}) {
let subtitle = `${version}`;

// TODO: Behind an if-statement because of https://github.com/npms-io/npms-api/issues/82
Expand All @@ -20,4 +19,4 @@ module.exports = ({author, date, publisher, version}) => {
}

return subtitle;
};
}
8 changes: 4 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ test('main', async t => {
mods: {
alt: {
arg: 'https://www.npmjs.com/package/chalk',
subtitle: 'Open the npm page instead of the GitHub repo'
subtitle: 'Open the npm page instead of the GitHub repo',
},
ctrl: {
arg: 'chalk',
subtitle: 'Copy package name'
}
subtitle: 'Copy package name',
},
},
quicklookurl: 'https://github.com/chalk/chalk#readme'
quicklookurl: 'https://github.com/chalk/chalk#readme',
});
});

Expand Down

0 comments on commit ced041d

Please sign in to comment.