mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-10 23:07:12 -05:00
Replace 'got' module with 'nets'. Resolves GH-802
This commit is contained in:
parent
140570d195
commit
a8c629dc9b
4 changed files with 27 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# NPM
|
# NPM
|
||||||
|
package-lock.json
|
||||||
/node_modules
|
/node_modules
|
||||||
npm-*
|
npm-*
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
"eslint-config-scratch": "^4.0.0",
|
"eslint-config-scratch": "^4.0.0",
|
||||||
"expose-loader": "0.7.3",
|
"expose-loader": "0.7.3",
|
||||||
"gh-pages": "^1.1.0",
|
"gh-pages": "^1.1.0",
|
||||||
"got": "5.7.1",
|
|
||||||
"highlightjs": "^9.8.0",
|
"highlightjs": "^9.8.0",
|
||||||
"htmlparser2": "3.9.2",
|
"htmlparser2": "3.9.2",
|
||||||
"immutable": "3.8.1",
|
"immutable": "3.8.1",
|
||||||
|
@ -44,6 +43,7 @@
|
||||||
"json": "^9.0.4",
|
"json": "^9.0.4",
|
||||||
"lodash.defaultsdeep": "4.6.0",
|
"lodash.defaultsdeep": "4.6.0",
|
||||||
"minilog": "3.1.0",
|
"minilog": "3.1.0",
|
||||||
|
"nets": "3.2.0",
|
||||||
"promise": "7.1.1",
|
"promise": "7.1.1",
|
||||||
"scratch-audio": "latest",
|
"scratch-audio": "latest",
|
||||||
"scratch-blocks": "latest",
|
"scratch-blocks": "latest",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const got = require('got');
|
const nets = require('nets');
|
||||||
const io = require('socket.io-client/dist/socket.io');
|
const io = require('socket.io-client/dist/socket.io');
|
||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
|
|
||||||
|
@ -312,7 +312,17 @@ class DeviceManager {
|
||||||
};
|
};
|
||||||
if (deviceSpec) queryObject.spec = deviceSpec;
|
if (deviceSpec) queryObject.spec = deviceSpec;
|
||||||
const url = `${this._serverURL}/${encodeURIComponent(deviceType)}/list?${querystring.stringify(queryObject)}`;
|
const url = `${this._serverURL}/${encodeURIComponent(deviceType)}/list?${querystring.stringify(queryObject)}`;
|
||||||
return got(url).then(response => JSON.parse(response.body));
|
return new Promise((resolve, reject) => {
|
||||||
|
nets({
|
||||||
|
method: 'GET',
|
||||||
|
url: url,
|
||||||
|
json: {}
|
||||||
|
}, (err, res, body) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
if (res.statusCode !== 200) reject(body);
|
||||||
|
resolve(body);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,3 +19,16 @@ test('default connected', t => {
|
||||||
t.strictEqual(deviceManager.isConnected, true);
|
t.strictEqual(deviceManager.isConnected, true);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('list', t => {
|
||||||
|
const deviceManager = new DeviceManager();
|
||||||
|
deviceManager
|
||||||
|
.list('test', 'test', null)
|
||||||
|
.catch(err => {
|
||||||
|
t.true((typeof err === 'undefined') || (typeof err === 'object'));
|
||||||
|
})
|
||||||
|
.then(body => {
|
||||||
|
t.true((typeof body === 'undefined') || (typeof body === 'object'));
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue