Skip to content

Commit

Permalink
fix: fix for compliance with new TypeScript rules
Browse files Browse the repository at this point in the history
  • Loading branch information
djcsdy committed Oct 12, 2022
1 parent cbe346a commit 4218211
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"@softwareventures/array": "^0.31.0 || ^0.33.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
"@softwareventures/chain": "^0.1.2 || ^1.0.0",
"@softwareventures/nullable": "^3.0.0",
"@types/mime": "^2.0.1 || ^3.0.0",
"aws-sdk": "^2.553.0 || ^2.884.0",
"globby": "^11.0.0",
Expand Down
5 changes: 3 additions & 2 deletions parallel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {notNull} from "@softwareventures/nullable";
import * as os from "os";

export default async function parallel<T>(tasks: ReadonlyArray<() => Promise<T>>, threads = 0): Promise<T[]> {
Expand All @@ -11,7 +12,7 @@ export default async function parallel<T>(tasks: ReadonlyArray<() => Promise<T>>
async function run(): Promise<void> {
const i = nextTaskIndex++;
if (i < tasks.length) {
const result = tasks[i]();
const result = notNull(tasks[i])();
results[i] = result;

return result.then(run);
Expand All @@ -27,4 +28,4 @@ export default async function parallel<T>(tasks: ReadonlyArray<() => Promise<T>>

return Promise.all(runs)
.then(() => Promise.all(results));
}
}
9 changes: 5 additions & 4 deletions publish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {concatMapFn, copy, mapFn} from "@softwareventures/array";
import chain from "@softwareventures/chain";
import {notNull} from "@softwareventures/nullable";
import {Credentials, S3} from "aws-sdk";
import * as fs from "fs";
import globby = require("globby");
Expand All @@ -18,8 +19,8 @@ export default async function publish(config: Config, context: Context): Promise

const {logger} = context;

const accessKeyId = context.env.AWS_ACCESS_KEY_ID;
const secretAccessKey = context.env.AWS_SECRET_ACCESS_KEY;
const accessKeyId = notNull(context.env["AWS_ACCESS_KEY_ID"]);
const secretAccessKey = notNull(context.env["AWS_SECRET_ACCESS_KEY"]);

const s3 = new S3({
apiVersion: "2006-03-01",
Expand Down Expand Up @@ -61,10 +62,10 @@ export default async function publish(config: Config, context: Context): Promise
Bucket: dest.bucket,
Key: dest.key,
Body: fs.createReadStream(file),
ContentType: dest.contentType || void 0
...(dest.contentType == null ? null : {ContentType: dest.contentType})
}, (err, data) => err ? reject(err) : resolve(data)));
})))
.map(async actions => actions.then(parallel))
.map(async result => result.then((_: ReadonlyArray<S3.PutObjectOutput>) => void 0))
.value;
}
}
7 changes: 5 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "@softwareventures/tslint-rules"
}
"extends": "@softwareventures/tslint-rules",
"rules": {
"no-string-literal": false
}
}
6 changes: 3 additions & 3 deletions verify-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {Config} from "./config";
export let verified = false;

export default async function verifyConditions(config: Config, context: Context): Promise<void> {
const accessKeyId = context.env.AWS_ACCESS_KEY_ID;
const secretAccessKey = context.env.AWS_SECRET_ACCESS_KEY;
const accessKeyId = context.env["AWS_ACCESS_KEY_ID"];
const secretAccessKey = context.env["AWS_SECRET_ACCESS_KEY"];

if (!accessKeyId || !secretAccessKey) {
throw new Error("Environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set");
}

verified = true;
}
}
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@
dependencies:
tslib "2.3.0"

"@softwareventures/nullable@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@softwareventures/nullable/-/nullable-3.0.0.tgz#979045c99e7c8a9055cb25c3c5cb5b9edfc50085"
integrity sha512-kgYOGJHzgZl0QGqMqbRe34i5VaRQUsG+X9AcblJL1lGDq+npLsCS974VSJmOBxnSqIQ5dcgah+zBxHndH8qzfg==
dependencies:
tslib "2.4.0"

"@softwareventures/ordered@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@softwareventures/ordered/-/ordered-1.1.0.tgz#5bd8929574d309738f6bcccaa017557979a4e303"
Expand Down

0 comments on commit 4218211

Please sign in to comment.