Skip to content

Commit

Permalink
Release 1.2.3
Browse files Browse the repository at this point in the history
Fixed:
- [Issue #37](#37)
  • Loading branch information
SaekiRaku committed Jun 22, 2020
1 parent 8c968f1 commit c3dec28
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to the "vscode-rainbow-fart" extension will be documented in

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [1.2.3] - 2020-06-22

### Fixed

- [Issue #37](https://github.com/SaekiRaku/vscode-rainbow-fart/issues/37)

## [1.2.2] - 2020-06-22

### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.2
1.2.3
8 changes: 7 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to the "vscode-rainbow-fart" extension will be documented in

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [1.2.2] - 2020-06-21
## [1.2.3] - 2020-06-22

### Fixed

- [Issue #37](https://github.com/SaekiRaku/vscode-rainbow-fart/issues/37)

## [1.2.2] - 2020-06-22

### Changed

Expand Down
2 changes: 1 addition & 1 deletion docs/global.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
window.VERSION = "1.2.2";
window.VERSION = "1.2.3";
window.URL_PREFIX = location.pathname === "/" ? "" : location.pathname;
7 changes: 1 addition & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "rainbow-fart",
"displayName": "🌈 Rainbow Fart",
"description": "This extension will keep giving you compliment while you are coding.",
"version": "1.2.2",
"version": "1.2.3",
"engines": {
"vscode": "^1.33.0"
},
Expand Down Expand Up @@ -49,7 +49,6 @@
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"get-port": "^5.1.1",
"glob": "^7.1.6",
"jszip": "^3.4.0",
"lodash": "^4.17.15",
Expand Down
42 changes: 42 additions & 0 deletions src/findAvailablePort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const net = require("net");

function tryToListen(host, port) {
return new Promise((resolve, reject) => {
var server = net.createServer();
server.listen(port, host);

server.on("listening", () => {
server.close();
resolve();
})

server.on("error", (err) => {
server.close();
reject(err);
})
});
}

async function checkAvailable(port) {
try {
await tryToListen("", port),
await tryToListen("::", port),
await tryToListen("0.0.0.0", port),
await tryToListen("127.0.0.1", port),
await tryToListen("localhost", port)
} catch (e) {
return false;
}
return true;
}

module.exports = async function(port) {
while (true) {
let available = await checkAvailable(port);
if (!available) {
port += Math.ceil(Math.random() * 7);
} else {
return port;
}
}
}
4 changes: 2 additions & 2 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const vscode = require("vscode");
const express = require("express")
const bodyParser = require("body-parser");
const multer = require('multer')
const getPort = require("get-port");
const findAvailablePort = require("./findAvailablePort.js");
const open = require("open");
const _ = require("lodash");

Expand All @@ -26,7 +26,7 @@ const settings = require("./settings.js");

module.exports = async function () {

let port = await getPort({ port: 7777 });
let port = await findAvailablePort(7777);

const app = express();

Expand Down

0 comments on commit c3dec28

Please sign in to comment.