diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 3c3629e..239ecff 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +yarn.lock diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.travis.yml b/.travis.yml index b18bae5..f98fed0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ -sudo: false language: node_js node_js: - - '6' - - '4' + - '12' + - '10' + - '8' diff --git a/index.js b/index.js index 72086e2..aac1265 100644 --- a/index.js +++ b/index.js @@ -9,14 +9,14 @@ module.exports = input => new Promise((resolve, reject) => { input = input.replace(/^(?!(?:https|git):\/\/)/, 'https://'); const tcp = net.connect({ - host: url.parse(input).host, + host: url.parse(input).host, // eslint-disable-line node/no-deprecated-api port: 9418 }); const client = gitclient(input); const tags = new Map(); client.refs.on('data', ref => { - const name = ref.name; + const {name} = ref; if (/^refs\/tags/.test(name)) { // Strip off the indicator of dereferenced tags so we can diff --git a/license b/license index 654d0bf..e7af2f7 100644 --- a/license +++ b/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/package.json b/package.json index d035994..c17efed 100644 --- a/package.json +++ b/package.json @@ -1,44 +1,42 @@ { - "name": "remote-git-tags", - "version": "2.0.0", - "description": "Get tags from a remote Git repo. Using only JS. No Git binary required.", - "license": "MIT", - "repository": "sindresorhus/remote-git-tags", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "git", - "tags", - "tag", - "remote", - "repo", - "repository", - "vanilla", - "js", - "javascript", - "ls", - "commit", - "sha", - "url" - ], - "dependencies": { - "git-fetch-pack": "^0.1.1", - "git-transport-protocol": "^0.1.0" - }, - "devDependencies": { - "ava": "*", - "xo": "*" - } + "name": "remote-git-tags", + "version": "2.0.0", + "description": "Get tags from a remote Git repo", + "license": "MIT", + "repository": "sindresorhus/remote-git-tags", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "git", + "tags", + "tag", + "remote", + "ls-remote", + "ls", + "repo", + "repository", + "commit", + "sha", + "url" + ], + "dependencies": { + "git-fetch-pack": "^0.1.1", + "git-transport-protocol": "^0.1.0" + }, + "devDependencies": { + "ava": "^2.1.0", + "xo": "^0.24.0" + } } diff --git a/readme.md b/readme.md index ed12830..90559ff 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # remote-git-tags [![Build Status](https://travis-ci.org/sindresorhus/remote-git-tags.svg?branch=master)](https://travis-ci.org/sindresorhus/remote-git-tags) -> Get tags from a remote git repo +> Get tags from a remote Git repo Like [`git ls-remote`](http://git-scm.com/docs/git-ls-remote.html), which doesn't require cloning the repo, but this is 100% JavaScript, meaning no dependency on the Git binary. @@ -12,7 +12,7 @@ I'm using this successfully against GitHub repos, but the underlaying modules ar ## Install ``` -$ npm install --save remote-git-tags +$ npm install remote-git-tags ``` @@ -21,10 +21,10 @@ $ npm install --save remote-git-tags ```js const remoteGitTags = require('remote-git-tags'); -remoteGitTags('github.com/sindresorhus/remote-git-tags').then(tags => { - console.log(tags); - //=> Map {'v1.0.0' => '69e308412e2a5cffa692951f0274091ef23e0e32'} -}); +(async () => { + console.log(await remoteGitTags('https://github.com/sindresorhus/remote-git-tags')); + //=> Map {'v1.0.0' => '69e308412e2a5cffa692951f0274091ef23e0e32', …} +})(); ``` @@ -32,15 +32,10 @@ remoteGitTags('github.com/sindresorhus/remote-git-tags').then(tags => { ### remoteGitTags(url) -Returns a `Promise` with the Git tags as keys and their commit SHA as values. +Returns a `Promise>` with the Git tags as keys and their commit SHA as values. #### url Type: `string` Git repo URL. - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index 30264e0..718f60f 100644 --- a/test.js +++ b/test.js @@ -1,8 +1,8 @@ import test from 'ava'; -import m from '.'; +import remoteGitTags from '.'; -test(async t => { - const tags = await m('github.com/sindresorhus/got'); +test('main', async t => { + const tags = await remoteGitTags('https://github.com/sindresorhus/got'); t.is(tags.get('v6.0.0'), 'e5c2d9e93137263c68db985b3dc5b57865c67b82'); t.is(tags.get('v5.0.0'), '0933d0bb13f704bc9aabcc1eec7a8e33dc8aba51'); });