summaryrefslogtreecommitdiff
path: root/std/fs
diff options
context:
space:
mode:
Diffstat (limited to 'std/fs')
-rw-r--r--std/fs/expand_glob.ts9
-rw-r--r--std/fs/walk.ts8
2 files changed, 12 insertions, 5 deletions
diff --git a/std/fs/expand_glob.ts b/std/fs/expand_glob.ts
index 7e575a123..656852ebb 100644
--- a/std/fs/expand_glob.ts
+++ b/std/fs/expand_glob.ts
@@ -9,6 +9,7 @@ import {
normalize
} from "../path/mod.ts";
import { WalkInfo, walk, walkSync } from "./walk.ts";
+import { assert } from "../testing/mod.ts";
const { ErrorKind, cwd, stat, statSync } = Deno;
type ErrorKind = Deno.ErrorKind;
type DenoError = Deno.DenoError<ErrorKind>;
@@ -80,7 +81,9 @@ export async function* expandGlob(
let fixedRoot = winRoot != undefined ? winRoot : "/";
while (segments.length > 0 && !isGlob(segments[0])) {
- fixedRoot = joinGlobs([fixedRoot, segments.shift()!], globOptions);
+ const seg = segments.shift();
+ assert(seg != null);
+ fixedRoot = joinGlobs([fixedRoot, seg], globOptions);
}
let fixedRootInfo: WalkInfo;
@@ -182,7 +185,9 @@ export function* expandGlobSync(
let fixedRoot = winRoot != undefined ? winRoot : "/";
while (segments.length > 0 && !isGlob(segments[0])) {
- fixedRoot = joinGlobs([fixedRoot, segments.shift()!], globOptions);
+ const seg = segments.shift();
+ assert(seg != null);
+ fixedRoot = joinGlobs([fixedRoot, seg], globOptions);
}
let fixedRootInfo: WalkInfo;
diff --git a/std/fs/walk.ts b/std/fs/walk.ts
index 1655b63ab..108eebc46 100644
--- a/std/fs/walk.ts
+++ b/std/fs/walk.ts
@@ -1,7 +1,7 @@
// Documentation and interface for walk were adapted from Go
// https://golang.org/pkg/path/filepath/#Walk
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
-import { unimplemented } from "../testing/asserts.ts";
+import { unimplemented, assert } from "../testing/asserts.ts";
import { join } from "../path/mod.ts";
const { readDir, readDirSync, stat, statSync } = Deno;
type FileInfo = Deno.FileInfo;
@@ -90,7 +90,8 @@ export async function* walk(
}
}
- const filename = join(root, info.name!);
+ assert(info.name != null);
+ const filename = join(root, info.name);
if (info.isFile()) {
if (includeFiles && include(filename, exts, match, skip)) {
@@ -142,7 +143,8 @@ export function* walkSync(
}
}
- const filename = join(root, info.name!);
+ assert(info.name != null);
+ const filename = join(root, info.name);
if (info.isFile()) {
if (includeFiles && include(filename, exts, match, skip)) {