summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-01-06 14:19:15 -0500
committerGitHub <noreply@github.com>2019-01-06 14:19:15 -0500
commitc164e696d7f924fe785421058d834934b7014429 (patch)
tree90af4dd0f6f5bd2e3149c8af1f8fc8b1247d03dc
parent68584f983e4b1cf81d84cdb57bb5459127293cd2 (diff)
Fix format globs (denoland/deno_std#87)
Original: https://github.com/denoland/deno_std/commit/297cf0975eca194a677e6fadd7d753d62eb453c3
-rwxr-xr-xformat.ts6
-rw-r--r--logging/handlers.ts13
-rw-r--r--logging/index.ts34
-rw-r--r--logging/logger.ts10
-rw-r--r--logging/test.ts3
-rw-r--r--net/bufio_test.ts6
-rw-r--r--net/file_server_test.ts10
-rw-r--r--net/http_test.ts6
-rw-r--r--net/textproto_test.ts6
-rw-r--r--testing/README.md18
10 files changed, 56 insertions, 56 deletions
diff --git a/format.ts b/format.ts
index c11d4e7b9..f1fa19e23 100755
--- a/format.ts
+++ b/format.ts
@@ -27,7 +27,11 @@ async function main() {
await checkVersion();
const prettier = run({
- args: ["bash", "-c", "prettier --write *.ts */**/*.ts *.md */**/*.md"]
+ args: [
+ "bash",
+ "-c",
+ "prettier --write *.ts */*.ts */**/*.ts *.md */**/*.md"
+ ]
});
const s = await prettier.status();
exit(s.code);
diff --git a/logging/handlers.ts b/logging/handlers.ts
index 747cf6bc1..a0163e6cd 100644
--- a/logging/handlers.ts
+++ b/logging/handlers.ts
@@ -20,19 +20,17 @@ export class BaseHandler {
return this.log(msg);
}
- log(msg: string) { }
- async setup() { }
- async destroy() { }
+ log(msg: string) {}
+ async setup() {}
+ async destroy() {}
}
-
export class ConsoleHandler extends BaseHandler {
log(msg: string) {
console.log(msg);
}
}
-
export abstract class WriterHandler extends BaseHandler {
protected _writer: Writer;
@@ -43,7 +41,6 @@ export abstract class WriterHandler extends BaseHandler {
}
}
-
export class FileHandler extends WriterHandler {
private _file: File;
private _filename: string;
@@ -55,11 +52,11 @@ export class FileHandler extends WriterHandler {
async setup() {
// open file in append mode - write only
- this._file = await open(this._filename, 'a');
+ this._file = await open(this._filename, "a");
this._writer = this._file;
}
async destroy() {
await this._file.close();
}
-} \ No newline at end of file
+}
diff --git a/logging/index.ts b/logging/index.ts
index 2b2394043..e8c762ac6 100644
--- a/logging/index.ts
+++ b/logging/index.ts
@@ -1,5 +1,10 @@
import { Logger } from "./logger.ts";
-import { BaseHandler, ConsoleHandler, WriterHandler, FileHandler } from "./handlers.ts";
+import {
+ BaseHandler,
+ ConsoleHandler,
+ WriterHandler,
+ FileHandler
+} from "./handlers.ts";
export class LoggerConfig {
level?: string;
@@ -18,14 +23,12 @@ export interface LogConfig {
const DEFAULT_LEVEL = "INFO";
const DEFAULT_NAME = "";
const DEFAULT_CONFIG: LogConfig = {
- handlers: {
-
- },
+ handlers: {},
loggers: {
"": {
level: "INFO",
- handlers: [""],
+ handlers: [""]
}
}
};
@@ -38,21 +41,26 @@ const state = {
defaultLogger,
handlers: new Map(),
loggers: new Map(),
- config: DEFAULT_CONFIG,
+ config: DEFAULT_CONFIG
};
export const handlers = {
BaseHandler,
ConsoleHandler,
WriterHandler,
- FileHandler,
+ FileHandler
};
-export const debug = (msg: string, ...args: any[]) => defaultLogger.debug(msg, ...args);
-export const info = (msg: string, ...args: any[]) => defaultLogger.info(msg, ...args);
-export const warning = (msg: string, ...args: any[]) => defaultLogger.warning(msg, ...args);
-export const error = (msg: string, ...args: any[]) => defaultLogger.error(msg, ...args);
-export const critical = (msg: string, ...args: any[]) => defaultLogger.critical(msg, ...args);
+export const debug = (msg: string, ...args: any[]) =>
+ defaultLogger.debug(msg, ...args);
+export const info = (msg: string, ...args: any[]) =>
+ defaultLogger.info(msg, ...args);
+export const warning = (msg: string, ...args: any[]) =>
+ defaultLogger.warning(msg, ...args);
+export const error = (msg: string, ...args: any[]) =>
+ defaultLogger.error(msg, ...args);
+export const critical = (msg: string, ...args: any[]) =>
+ defaultLogger.critical(msg, ...args);
export function getLogger(name?: string) {
if (!name) {
@@ -108,4 +116,4 @@ export async function setup(config: LogConfig) {
}
}
-setup(DEFAULT_CONFIG); \ No newline at end of file
+setup(DEFAULT_CONFIG);
diff --git a/logging/logger.ts b/logging/logger.ts
index 798181599..9f34f9c32 100644
--- a/logging/logger.ts
+++ b/logging/logger.ts
@@ -7,7 +7,7 @@ export interface LogRecord {
datetime: Date;
level: number;
levelName: string;
-};
+}
export class Logger {
level: number;
@@ -17,14 +17,14 @@ export class Logger {
constructor(levelName: string, handlers?: BaseHandler[]) {
this.level = getLevelByName(levelName);
this.levelName = levelName;
-
+
this.handlers = handlers || [];
}
_log(level: number, msg: string, ...args: any[]) {
if (this.level > level) return;
- // TODO: it'd be a good idea to make it immutable, so
+ // TODO: it'd be a good idea to make it immutable, so
// no handler mangles it by mistake
// TODO: iterpolate msg with values
const record: LogRecord = {
@@ -32,8 +32,8 @@ export class Logger {
args: args,
datetime: new Date(),
level: level,
- levelName: getLevelName(level),
- }
+ levelName: getLevelName(level)
+ };
this.handlers.forEach(handler => {
handler.handle(record);
diff --git a/logging/test.ts b/logging/test.ts
index a3c0b7199..17117ae8b 100644
--- a/logging/test.ts
+++ b/logging/test.ts
@@ -23,7 +23,6 @@ test(function testDefaultlogMethods() {
log.error("Foobar");
log.critical("Foobar");
- const logger = log.getLogger('');
+ const logger = log.getLogger("");
console.log(logger);
});
-
diff --git a/net/bufio_test.ts b/net/bufio_test.ts
index 411f173f4..fa8f4b73b 100644
--- a/net/bufio_test.ts
+++ b/net/bufio_test.ts
@@ -4,11 +4,7 @@
// license that can be found in the LICENSE file.
import { Buffer, Reader, ReadResult } from "deno";
-import {
- test,
- assert,
- assertEqual
-} from "../testing/mod.ts";
+import { test, assert, assertEqual } from "../testing/mod.ts";
import { BufReader, BufState, BufWriter } from "./bufio.ts";
import * as iotest from "./iotest.ts";
import { charCode, copyBytes, stringsReader } from "./util.ts";
diff --git a/net/file_server_test.ts b/net/file_server_test.ts
index e0abb1cf1..28357c912 100644
--- a/net/file_server_test.ts
+++ b/net/file_server_test.ts
@@ -1,10 +1,6 @@
import { readFile } from "deno";
-import {
- test,
- assert,
- assertEqual
-} from "../testing/mod.ts";
+import { test, assert, assertEqual } from "../testing/mod.ts";
// Promise to completeResolve when all tests completes
let completeResolve;
@@ -27,7 +23,9 @@ export function runTests(serverReadyPromise: Promise<any>) {
assert(res.headers.has("access-control-allow-headers"));
assertEqual(res.headers.get("content-type"), "text/yaml");
const downloadedFile = await res.text();
- const localFile = new TextDecoder().decode(await readFile("./azure-pipelines.yml"));
+ const localFile = new TextDecoder().decode(
+ await readFile("./azure-pipelines.yml")
+ );
assertEqual(downloadedFile, localFile);
maybeCompleteTests();
});
diff --git a/net/http_test.ts b/net/http_test.ts
index 46ea60185..9235feb02 100644
--- a/net/http_test.ts
+++ b/net/http_test.ts
@@ -6,11 +6,7 @@
// https://github.com/golang/go/blob/master/src/net/http/responsewrite_test.go
import { Buffer } from "deno";
-import {
- test,
- assert,
- assertEqual
-} from "../testing/mod.ts";
+import { test, assert, assertEqual } from "../testing/mod.ts";
import {
listenAndServe,
ServerRequest,
diff --git a/net/textproto_test.ts b/net/textproto_test.ts
index 9fe5e8dd3..e0ae0749c 100644
--- a/net/textproto_test.ts
+++ b/net/textproto_test.ts
@@ -6,11 +6,7 @@
import { BufReader } from "./bufio.ts";
import { TextProtoReader, append } from "./textproto.ts";
import { stringsReader } from "./util.ts";
-import {
- test,
- assert,
- assertEqual
-} from "../testing/mod.ts";
+import { test, assert, assertEqual } from "../testing/mod.ts";
function reader(s: string): TextProtoReader {
return new TextProtoReader(new BufReader(stringsReader(s)));
diff --git a/testing/README.md b/testing/README.md
index f9f47eaa6..70968e3c7 100644
--- a/testing/README.md
+++ b/testing/README.md
@@ -1,24 +1,30 @@
-# Testing
+# Testing
## Usage
```ts
-import { test, assert, equal, assertEqual } from 'https://deno.land/x/testing/mod.ts';
+import {
+ test,
+ assert,
+ equal,
+ assertEqual
+} from "https://deno.land/x/testing/mod.ts";
test({
- name: 'testing example',
+ name: "testing example",
fn() {
assert(equal("world", "world"));
assert(!equal("hello", "world"));
assert(equal({ hello: "world" }, { hello: "world" }));
assert(!equal({ world: "hello" }, { hello: "world" }));
assertEqual("world", "world");
- assertEqual({hello: "world"}, {hello: "world"});
- },
+ assertEqual({ hello: "world" }, { hello: "world" });
+ }
});
```
Short syntax (named function instead of object):
+
```ts
test(function example() {
assert(equal("world", "world"));
@@ -26,6 +32,6 @@ test(function example() {
assert(equal({ hello: "world" }, { hello: "world" }));
assert(!equal({ world: "hello" }, { hello: "world" }));
assertEqual("world", "world");
- assertEqual({hello: "world"}, {hello: "world"});
+ assertEqual({ hello: "world" }, { hello: "world" });
});
```