From 8ce0a6b4a9fb28f2d13cf310baec6722920c2ecd Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 22 Jun 2019 03:37:53 +0000 Subject: [PATCH 1/2] chore(deps): update dependency eslint to v6 --- appengine/websockets/package.json | 2 +- functions/dialogflow/functions/package.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appengine/websockets/package.json b/appengine/websockets/package.json index 42c9c8a4b8..86f188f73a 100644 --- a/appengine/websockets/package.json +++ b/appengine/websockets/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.3.0", - "eslint": "^5.4.0", + "eslint": "^6.0.0", "eslint-config-prettier": "^5.0.0", "eslint-plugin-node": "^9.0.0", "eslint-plugin-prettier": "^3.0.0", diff --git a/functions/dialogflow/functions/package.json b/functions/dialogflow/functions/package.json index ec30e50aa5..02c32f0269 100644 --- a/functions/dialogflow/functions/package.json +++ b/functions/dialogflow/functions/package.json @@ -19,7 +19,7 @@ "devDependencies": { "@google-cloud/functions-emulator": "^1.0.0-beta.5", "@google-cloud/nodejs-repo-tools": "^3.3.0", - "eslint": "^5.12.0", + "eslint": "^6.0.0", "eslint-plugin-promise": "^4.0.1", "mocha": "^6.0.2", "supertest": "^4.0.0" diff --git a/package.json b/package.json index 1197324e47..e9289f294e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.3.0", - "eslint": "^5.9.0", + "eslint": "^6.0.0", "eslint-config-prettier": "^5.0.0", "eslint-plugin-node": "^9.0.0", "eslint-plugin-prettier": "^3.1.0", From d78694939c4d92be2be710f48f544259d263a00c Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Sat, 22 Jun 2019 14:50:55 -0400 Subject: [PATCH 2/2] Fix linter --- appengine/headless-chrome/app.js | 70 ++++++++++++++-------------- functions/headless-chrome/index.js | 10 ++-- iot/beta-features/gateway/gateway.js | 15 ++---- 3 files changed, 44 insertions(+), 51 deletions(-) diff --git a/appengine/headless-chrome/app.js b/appengine/headless-chrome/app.js index 639a2ed6cb..ef19b94db4 100644 --- a/appengine/headless-chrome/app.js +++ b/appengine/headless-chrome/app.js @@ -20,40 +20,40 @@ const express = require('express'); const puppeteer = require('puppeteer'); const app = express(); -let browser; - -app.use(async (req, res) => { - const {url} = req.query; - - if (!url) { - return res.send( - 'Please provide URL as GET parameter, for example: ?url=https://example.com' - ); - } - - if (!browser) { - // [START gae_std_headless_chrome_full_sample_browser] - browser = await puppeteer.launch({ - args: ['--no-sandbox'], - }); - // [END gae_std_headless_chrome_full_sample_browser] - } - - const page = await browser.newPage(); - await page.goto(url); - const imageBuffer = await page.screenshot(); - - res.set('Content-Type', 'image/png'); - res.send(imageBuffer); -}); - -const server = app.listen(process.env.PORT || 8080, err => { - if (err) { - return console.error(err); - } - const {port} = server.address(); - console.info(`App listening on port ${port}`); -}); -// [END gae_std_headless_chrome_full_sample] +async function main() { + // [START gae_std_headless_chrome_full_sample_browser] + const browser = await puppeteer.launch({ + args: ['--no-sandbox'], + }); + // [END gae_std_headless_chrome_full_sample_browser] + + app.use(async (req, res) => { + const {url} = req.query; + + if (!url) { + return res.send( + 'Please provide URL as GET parameter, for example: ?url=https://example.com' + ); + } + + const page = await browser.newPage(); + await page.goto(url); + const imageBuffer = await page.screenshot(); + + res.set('Content-Type', 'image/png'); + res.send(imageBuffer); + }); + + const server = app.listen(process.env.PORT || 8080, err => { + if (err) { + return console.error(err); + } + const {port} = server.address(); + console.info(`App listening on port ${port}`); + }); + // [END gae_std_headless_chrome_full_sample] +} + +main(); module.exports = app; diff --git a/functions/headless-chrome/index.js b/functions/headless-chrome/index.js index 389c28003b..50110ebf64 100644 --- a/functions/headless-chrome/index.js +++ b/functions/headless-chrome/index.js @@ -27,6 +27,12 @@ async function getBrowserPage() { return browser.newPage(); } +async function main() { + page = await getBrowserPage(); +} + +main(); + exports.screenshot = async (req, res) => { const {url} = req.query; @@ -36,10 +42,6 @@ exports.screenshot = async (req, res) => { ); } - if (!page) { - page = await getBrowserPage(); - } - await page.goto(url); const imageBuffer = await page.screenshot(); res.set('Content-Type', 'image/png'); diff --git a/iot/beta-features/gateway/gateway.js b/iot/beta-features/gateway/gateway.js index 605b8fe9e0..d9c2345bd0 100644 --- a/iot/beta-features/gateway/gateway.js +++ b/iot/beta-features/gateway/gateway.js @@ -341,18 +341,9 @@ const unbindDeviceFromAllGateways = async ( }; // for each gateway, make the call to unbind it - return new Promise(async (resolve, reject) => { - try { - await client.projects.locations.registries.unbindDeviceFromGateway( - unbindRequest - ); - console.log('Unbound device from gateways', gateway.id); - resolve(); - } catch (err) { - console.log('Could not unbind device', err); - reject(); - } - }); + return client.projects.locations.registries.unbindDeviceFromGateway( + unbindRequest + ); }); await Promise.all(promises);