diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/copy.ts | 17 | ||||
-rw-r--r-- | fs/copy_test.ts | 3 | ||||
-rw-r--r-- | fs/ensure_file.ts | 12 | ||||
-rw-r--r-- | fs/exists.ts | 8 | ||||
-rw-r--r-- | fs/exists_test.ts | 6 | ||||
-rw-r--r-- | fs/glob.ts | 1 | ||||
-rw-r--r-- | fs/globrex.ts | 9 | ||||
-rw-r--r-- | fs/utils.ts | 3 |
8 files changed, 39 insertions, 20 deletions
diff --git a/fs/copy.ts b/fs/copy.ts index b51106e3a..c3c97d1ba 100644 --- a/fs/copy.ts +++ b/fs/copy.ts @@ -9,7 +9,8 @@ export interface CopyOptions { */ overwrite?: boolean; /** - * When `true`, will set last modification and access times to the ones of the original source files. + * When `true`, will set last modification and access times to the ones of the + * original source files. * When `false`, timestamp behavior is OS-dependent. * Default is `false`. */ @@ -188,9 +189,10 @@ function copyDirSync(src: string, dest: string, options: CopyOptions): void { /** * Copy a file or directory. The directory can have contents. Like `cp -r`. * @param src the file/directory path. - * Note that if `src` is a directory it will copy everything inside of this directory, - * not the entire directory itself - * @param dest the destination path. Note that if `src` is a file, `dest` cannot be a directory + * Note that if `src` is a directory it will copy everything inside + * of this directory, not the entire directory itself + * @param dest the destination path. Note that if `src` is a file, `dest` cannot + * be a directory * @param options */ export async function copy( @@ -225,9 +227,10 @@ export async function copy( /** * Copy a file or directory. The directory can have contents. Like `cp -r`. * @param src the file/directory path. - * Note that if `src` is a directory it will copy everything inside of this directory, - * not the entire directory itself - * @param dest the destination path. Note that if `src` is a file, `dest` cannot be a directory + * Note that if `src` is a directory it will copy everything inside + * of this directory, not the entire directory itself + * @param dest the destination path. Note that if `src` is a file, `dest` cannot + * be a directory * @param options */ export function copySync( diff --git a/fs/copy_test.ts b/fs/copy_test.ts index 38c27e15b..09aae0ff6 100644 --- a/fs/copy_test.ts +++ b/fs/copy_test.ts @@ -431,7 +431,8 @@ testCopySync( ); testCopySync( - "[fs] copy directory synchronously, and destination exist and not a directory", + "[fs] copy directory synchronously, and destination exist and not a " + + "directory", (tempDir: string): void => { const srcDir = path.join(tempDir, "parent_sync"); const destDir = path.join(tempDir, "child.txt"); diff --git a/fs/ensure_file.ts b/fs/ensure_file.ts index 6fe8e7822..d749b95e4 100644 --- a/fs/ensure_file.ts +++ b/fs/ensure_file.ts @@ -5,8 +5,10 @@ import { getFileInfoType } from "./utils.ts"; /** * Ensures that the file exists. - * If the file that is requested to be created is in directories that do not exist, - * these directories are created. If the file already exists, it is NOT MODIFIED. + * If the file that is requested to be created is in directories that do not + * exist. + * these directories are created. If the file already exists, + * it is NOTMODIFIED. */ export async function ensureFile(filePath: string): Promise<void> { let pathExists = false; @@ -33,8 +35,10 @@ export async function ensureFile(filePath: string): Promise<void> { /** * Ensures that the file exists. - * If the file that is requested to be created is in directories that do not exist, - * these directories are created. If the file already exists, it is NOT MODIFIED. + * If the file that is requested to be created is in directories that do not + * exist, + * these directories are created. If the file already exists, + * it is NOT MODIFIED. */ export function ensureFileSync(filePath: string): void { let pathExists = false; diff --git a/fs/exists.ts b/fs/exists.ts index 4638630fd..2c68ec6cf 100644 --- a/fs/exists.ts +++ b/fs/exists.ts @@ -1,13 +1,17 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -/** Test whether or not the given path exists by checking with the file system */ +/** + * Test whether or not the given path exists by checking with the file system + */ export async function exists(filePath: string): Promise<boolean> { return Deno.lstat(filePath) .then((): boolean => true) .catch((): boolean => false); } -/** Test whether or not the given path exists by checking with the file system */ +/** + * Test whether or not the given path exists by checking with the file system + */ export function existsSync(filePath: string): boolean { try { Deno.lstatSync(filePath); diff --git a/fs/exists_test.ts b/fs/exists_test.ts index a75cdb9f4..247bb7ed6 100644 --- a/fs/exists_test.ts +++ b/fs/exists_test.ts @@ -36,11 +36,13 @@ test(function existsDirectorySync(): void { }); test(function existsLinkSync(): void { - // TODO(axetroy): generate link file use Deno api instead of set a link file in repository + // TODO(axetroy): generate link file use Deno api instead of set a link file + // in repository assertEquals(existsSync(path.join(testdataDir, "0-link.ts")), true); }); test(async function existsLink(): Promise<void> { - // TODO(axetroy): generate link file use Deno api instead of set a link file in repository + // TODO(axetroy): generate link file use Deno api instead of set a link file + // in repository assertEquals(await exists(path.join(testdataDir, "0-link.ts")), true); }); diff --git a/fs/glob.ts b/fs/glob.ts index 8d322b761..506d4012c 100644 --- a/fs/glob.ts +++ b/fs/glob.ts @@ -47,6 +47,7 @@ export function glob(glob: string, options: GlobOptions = {}): RegExp { /** Test whether the given string is a glob */ export function isGlob(str: string): boolean { const chars: Record<string, string> = { "{": "}", "(": ")", "[": "]" }; + /* eslint-disable-next-line max-len */ const regex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; if (str === "") { diff --git a/fs/globrex.ts b/fs/globrex.ts index 56def02f8..32a129a67 100644 --- a/fs/globrex.ts +++ b/fs/globrex.ts @@ -76,7 +76,8 @@ export function globrex( if (split) { if (last) segment += str; if (segment !== "") { - if (!flags.includes("g")) segment = `^${segment}$`; // change it 'includes' + // change it 'includes' + if (!flags.includes("g")) segment = `^${segment}$`; path.segments.push(new RegExp(segment, flags)); } segment = ""; @@ -265,8 +266,10 @@ export function globrex( // globstar is enabled, so determine if this is a globstar segment let isGlobstar = starCount > 1 && // multiple "*"'s - (prevChar === "/" || prevChar === undefined) && // from the start of the segment - (nextChar === "/" || nextChar === undefined); // to the end of the segment + // from the start of the segment + (prevChar === "/" || prevChar === undefined) && + // to the end of the segment + (nextChar === "/" || nextChar === undefined); if (isGlobstar) { // it's a globstar, so match zero or more path segments add(GLOBSTAR, { only: "regex" }); diff --git a/fs/utils.ts b/fs/utils.ts index ab5bf2f0e..f644f4869 100644 --- a/fs/utils.ts +++ b/fs/utils.ts @@ -31,7 +31,8 @@ export type PathType = "file" | "dir" | "symlink"; /** * Get a human readable file type string. * - * @param fileInfo A FileInfo describes a file and is returned by `stat`, `lstat` + * @param fileInfo A FileInfo describes a file and is returned by `stat`, + * `lstat` */ export function getFileInfoType(fileInfo: Deno.FileInfo): PathType | undefined { return fileInfo.isFile() |