Skip to content

Commit

Permalink
fix: modernize, semantic release, ignore files
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Rodriguez Baquero committed Jun 15, 2021
1 parent f874416 commit 79ecf6b
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 16 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: ci
on: [push, pull_request]
jobs:
test:
name: Node ${{ matrix.node }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
node:
- '14'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ runner.node }}
- run: npm install
- run: npm run build --if-present
- run: npm test
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm i
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
package-lock.json
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.travis.yml
test/
*
!index.js
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

12 changes: 5 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = () => {
}

_addPeer (peer, flags, version) {
if (peer.indexOf(':') < 0) return // disregard invalid peers
if (!peer.includes(':')) return // disregard invalid peers
if (peer in this._remoteAddedPeers) return // never advertise peer the remote wire already sent us
if (peer in this._localDroppedPeers) delete this._localDroppedPeers[peer]
this._localAddedPeers[peer] = { ip: version, flags: flags }
Expand All @@ -93,7 +93,7 @@ module.exports = () => {
}

_dropPeer (peer, version) {
if (peer.indexOf(':') < 0) return // disregard invalid peers
if (!peer.includes(':')) return // disregard invalid peers
if (peer in this._remoteDroppedPeers) return // never advertise peer the remote wire already sent us
if (peer in this._localAddedPeers) delete this._localAddedPeers[peer]
this._localDroppedPeers[peer] = { ip: version }
Expand Down Expand Up @@ -200,11 +200,9 @@ module.exports = () => {
* @returns {Number} one byte number
*/
_encodeFlags (flags) {
return Object.keys(flags).reduce((acc, cur) => {
return (flags[cur] === true)
? acc | FLAGS[cur]
: acc
}, 0x00)
return Object.keys(flags).reduce((acc, cur) => (flags[cur] === true)
? acc | FLAGS[cur]
: acc, 0x00)
}

/**
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"string2compact": "^1.3.0"
},
"devDependencies": {
"@webtorrent/semantic-release-config": "1.0.5",
"bittorrent-protocol": "3.3.1",
"nyc": "15.1.0",
"semantic-release": "17.4.3",
"standard": "*",
"tape": "5.2.2"
},
Expand Down Expand Up @@ -57,10 +59,7 @@
"renovate": {
"extends": [
"github>webtorrent/renovate-config"
],
"lockFileMaintenance": {
"enabled": false
}
]
},
"release": {
"extends": "@webtorrent/semantic-release-config"
Expand Down

0 comments on commit 79ecf6b

Please sign in to comment.