Skip to content

Commit

Permalink
Convert queue.js to TypeScript (#1000)
Browse files Browse the repository at this point in the history
* Convert queue.js to TypeScript

* Update src/queue.ts

Co-Authored-By: mbleigh <mbleigh@mbleigh.com>

* Update src/queue.ts

Co-Authored-By: mbleigh <mbleigh@mbleigh.com>

* Update src/queue.ts

Co-Authored-By: mbleigh <mbleigh@mbleigh.com>

* Update src/deploy/hosting/uploader.js

Co-Authored-By: mbleigh <mbleigh@mbleigh.com>

* Address comments.
  • Loading branch information
mbleigh authored and bkendall committed Nov 6, 2018
1 parent 645483a commit 16c5114
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 217 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"trailingComma": "es5",
"printWidth": 100
"printWidth": 100,
"arrowParens": "always"
}
8 changes: 4 additions & 4 deletions src/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ if (previews.emulators) {
VALID_TARGETS = ["functions", "hosting", "database", "firestore"];
}

var filterOnlyEmulators = only => {
var filterOnlyEmulators = (only) => {
if (!only) {
return [];
}
return _.intersection(
VALID_EMULATORS,
only.split(",").map(opt => {
only.split(",").map((opt) => {
return opt.split(":")[0];
})
);
Expand All @@ -46,7 +46,7 @@ module.exports = new Command("serve")
"--except <targets>",
"serve all except specified targets (valid targets are: " + VALID_TARGETS.join(", ") + ")"
)
.before(options => {
.before((options) => {
if (filterOnlyEmulators(options.only).length > 0) {
return Promise.resolve();
}
Expand All @@ -55,7 +55,7 @@ module.exports = new Command("serve")
.then(() => checkDupHostingKeys(options))
.then(() => getProjectNumber(options));
})
.action(options => {
.action((options) => {
options.targets = filterOnlyEmulators(options.only);
if (options.targets.length > 0) {
return serve(options);
Expand Down
2 changes: 1 addition & 1 deletion src/deploy/hosting/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const hashcache = require("./hashcache");
const detectProjectRoot = require("../../detectProjectRoot");
const api = require("../../api");
const logger = require("../../logger");
const Queue = require("../../queue");
const { Queue } = require("../../queue");

const MIN_UPLOAD_TIMEOUT = 30000; // 30s
const MAX_UPLOAD_TIMEOUT = 7200000; // 2h
Expand Down
4 changes: 2 additions & 2 deletions src/emulator/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const request = require("request");
const emulatorConstants = require("./constants");
const utils = require("../utils");

module.exports = name => {
module.exports = (name) => {
return new Promise((resolve, reject) => {
utils.logLabeledBullet(name, "downloading emulator...");
let emulator = emulatorConstants.emulators[name];
fs.ensureDirSync(emulator.cacheDir);
let req = request.get(emulator.remoteUrl);
let writeStream = fs.createWriteStream(emulator.localPath);
req.on("error", err => reject(err));
req.on("error", (err) => reject(err));
req.on("end", () => {
writeStream.close();
fs.chmodSync(emulator.localPath, 0o755);
Expand Down
6 changes: 3 additions & 3 deletions src/firebaseApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function _list(nextPageToken, projects) {
auth: true,
origin: api.firebaseApiOrigin,
})
.then(response => {
.then((response) => {
projects = projects.concat(response.body.results);
if (response.body.nextPageToken) {
return _list(response.body.nextPageToken, projects);
Expand All @@ -26,10 +26,10 @@ function _list(nextPageToken, projects) {

exports.listProjects = () => _list();

exports.getProject = projectId =>
exports.getProject = (projectId) =>
api
.request("GET", `/${API_VERSION}/projects/${projectId}`, {
auth: true,
origin: api.firebaseApiOrigin,
})
.then(response => response.body);
.then((response) => response.body);
4 changes: 2 additions & 2 deletions src/init/features/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function _getProject(options) {

// Load all projects and prompt the user to choose.
return firebaseApi.listProjects().then(function(projects) {
var choices = projects.filter(project => !!project).map(project => {
var choices = projects.filter((project) => !!project).map((project) => {
return {
name: project.projectId,
label: project.projectId + " (" + project.displayName + ")",
Expand Down Expand Up @@ -82,7 +82,7 @@ function _getProject(options) {
}

var id = prompt.listLabelToValue(label, choices);
const project = projects.find(p => p.projectId === id);
const project = projects.find((p) => p.projectId === id);
return {
id: id,
label: label,
Expand Down
168 changes: 0 additions & 168 deletions src/queue.js

This file was deleted.

0 comments on commit 16c5114

Please sign in to comment.