Skip to content

Commit

Permalink
chore: change to two space indents for internal code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Nov 13, 2021
1 parent 3ba4f63 commit cea07aa
Show file tree
Hide file tree
Showing 981 changed files with 91,709 additions and 89,648 deletions.
352 changes: 176 additions & 176 deletions deno/common/DenoRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,191 +3,191 @@ import { expandGlob, expandGlobSync } from "https://deno.land/std@0.106.0/fs/exp
import * as stdPath from "https://deno.land/std@0.106.0/path/mod.ts";

export class DenoRuntime {
fs = new DenoRuntimeFileSystem();
path = new DenoRuntimePath();

getEnvVar(name: string) {
return Deno.env.get(name);
}

getEndOfLine() {
return Deno.build.os === "windows" ? "\r\n" : "\n";
}

getPathMatchesPattern(path: string, pattern: string) {
return stdPath.globToRegExp(pattern, {
extended: true,
globstar: true,
os: "linux", // use the same behaviour across all operating systems
}).test(path);
}
fs = new DenoRuntimeFileSystem();
path = new DenoRuntimePath();

getEnvVar(name: string) {
return Deno.env.get(name);
}

getEndOfLine() {
return Deno.build.os === "windows" ? "\r\n" : "\n";
}

getPathMatchesPattern(path: string, pattern: string) {
return stdPath.globToRegExp(pattern, {
extended: true,
globstar: true,
os: "linux", // use the same behaviour across all operating systems
}).test(path);
}
}

class DenoRuntimePath {
join(...paths: string[]) {
return stdPath.join(...paths);
}
join(...paths: string[]) {
return stdPath.join(...paths);
}

normalize(path: string) {
return stdPath.normalize(path);
}
normalize(path: string) {
return stdPath.normalize(path);
}

relative(from: string, to: string) {
return stdPath.relative(from, to);
}
relative(from: string, to: string) {
return stdPath.relative(from, to);
}
}

class DenoRuntimeFileSystem {
delete(path: string) {
return Deno.remove(path);
}

deleteSync(path: string) {
Deno.removeSync(path);
}

readDirSync(dirPath: string) {
return Array.from(Deno.readDirSync(dirPath));
}

readFile(filePath: string, _encoding = "utf-8") {
return Deno.readTextFile(filePath);
}

readFileSync(filePath: string, _encoding = "utf-8") {
return Deno.readTextFileSync(filePath);
}

writeFile(filePath: string, fileText: string) {
return Deno.writeTextFile(filePath, fileText);
}

writeFileSync(filePath: string, fileText: string) {
return Deno.writeTextFileSync(filePath, fileText);
}

async mkdir(dirPath: string) {
await ensureDir(dirPath);
}

mkdirSync(dirPath: string) {
ensureDirSync(dirPath);
}

move(srcPath: string, destPath: string) {
return Deno.rename(srcPath, destPath);
}

moveSync(srcPath: string, destPath: string) {
Deno.renameSync(srcPath, destPath);
}

copy(srcPath: string, destPath: string) {
return Deno.copyFile(srcPath, destPath);
}

copySync(srcPath: string, destPath: string) {
return Deno.copyFileSync(srcPath, destPath);
}

async fileExists(filePath: string) {
try {
const stat = await Deno.stat(filePath);
return stat.isFile;
} catch {
return false;
}
}

fileExistsSync(filePath: string) {
try {
return Deno.statSync(filePath).isFile;
} catch {
return false;
}
}

async directoryExists(dirPath: string) {
try {
const stat = await Deno.stat(dirPath);
return stat.isDirectory;
} catch {
return false;
}
}

directoryExistsSync(dirPath: string) {
try {
return Deno.statSync(dirPath).isDirectory;
} catch (err) {
return false;
}
}

realpathSync(path: string) {
return Deno.realPathSync(path);
}

getCurrentDirectory(): string {
return Deno.cwd();
}

async glob(patterns: ReadonlyArray<string>) {
const { excludePatterns, pattern } = globPatternsToPattern(patterns);
const result: string[] = [];
const globEntries = expandGlob(pattern, {
root: this.getCurrentDirectory(),
extended: true,
globstar: true,
exclude: excludePatterns,
});
for await (const globEntry of globEntries) {
if (globEntry.isFile)
result.push(globEntry.path);
}
return result;
}

globSync(patterns: ReadonlyArray<string>) {
const { excludePatterns, pattern } = globPatternsToPattern(patterns);
const result: string[] = [];
const globEntries = expandGlobSync(pattern, {
root: this.getCurrentDirectory(),
extended: true,
globstar: true,
exclude: excludePatterns,
});
for (const globEntry of globEntries) {
if (globEntry.isFile)
result.push(globEntry.path);
}
return result;
}

isCaseSensitive() {
const platform = Deno.build.os;
return platform !== "windows" && platform !== "darwin";
}
delete(path: string) {
return Deno.remove(path);
}

deleteSync(path: string) {
Deno.removeSync(path);
}

readDirSync(dirPath: string) {
return Array.from(Deno.readDirSync(dirPath));
}

readFile(filePath: string, _encoding = "utf-8") {
return Deno.readTextFile(filePath);
}

readFileSync(filePath: string, _encoding = "utf-8") {
return Deno.readTextFileSync(filePath);
}

writeFile(filePath: string, fileText: string) {
return Deno.writeTextFile(filePath, fileText);
}

writeFileSync(filePath: string, fileText: string) {
return Deno.writeTextFileSync(filePath, fileText);
}

async mkdir(dirPath: string) {
await ensureDir(dirPath);
}

mkdirSync(dirPath: string) {
ensureDirSync(dirPath);
}

move(srcPath: string, destPath: string) {
return Deno.rename(srcPath, destPath);
}

moveSync(srcPath: string, destPath: string) {
Deno.renameSync(srcPath, destPath);
}

copy(srcPath: string, destPath: string) {
return Deno.copyFile(srcPath, destPath);
}

copySync(srcPath: string, destPath: string) {
return Deno.copyFileSync(srcPath, destPath);
}

async fileExists(filePath: string) {
try {
const stat = await Deno.stat(filePath);
return stat.isFile;
} catch {
return false;
}
}

fileExistsSync(filePath: string) {
try {
return Deno.statSync(filePath).isFile;
} catch {
return false;
}
}

async directoryExists(dirPath: string) {
try {
const stat = await Deno.stat(dirPath);
return stat.isDirectory;
} catch {
return false;
}
}

directoryExistsSync(dirPath: string) {
try {
return Deno.statSync(dirPath).isDirectory;
} catch (err) {
return false;
}
}

realpathSync(path: string) {
return Deno.realPathSync(path);
}

getCurrentDirectory(): string {
return Deno.cwd();
}

async glob(patterns: ReadonlyArray<string>) {
const { excludePatterns, pattern } = globPatternsToPattern(patterns);
const result: string[] = [];
const globEntries = expandGlob(pattern, {
root: this.getCurrentDirectory(),
extended: true,
globstar: true,
exclude: excludePatterns,
});
for await (const globEntry of globEntries) {
if (globEntry.isFile)
result.push(globEntry.path);
}
return result;
}

globSync(patterns: ReadonlyArray<string>) {
const { excludePatterns, pattern } = globPatternsToPattern(patterns);
const result: string[] = [];
const globEntries = expandGlobSync(pattern, {
root: this.getCurrentDirectory(),
extended: true,
globstar: true,
exclude: excludePatterns,
});
for (const globEntry of globEntries) {
if (globEntry.isFile)
result.push(globEntry.path);
}
return result;
}

isCaseSensitive() {
const platform = Deno.build.os;
return platform !== "windows" && platform !== "darwin";
}
}

function globPatternsToPattern(patterns: ReadonlyArray<string>) {
const excludePatterns = [];
const includePatterns = [];

for (const pattern of patterns) {
if (isNegatedGlob(pattern))
excludePatterns.push(pattern);
else
includePatterns.push(pattern);
}

return {
excludePatterns,
pattern: includePatterns.length === 0 ? "." : includePatterns.length === 1 ? includePatterns[0] : `{${includePatterns.join(",")}}`,
};

function isNegatedGlob(glob: string) {
// https://github.com/micromatch/is-negated-glob/blob/master/index.js
return glob[0] === "!" && glob[1] !== "(";
}
const excludePatterns = [];
const includePatterns = [];

for (const pattern of patterns) {
if (isNegatedGlob(pattern))
excludePatterns.push(pattern);
else
includePatterns.push(pattern);
}

return {
excludePatterns,
pattern: includePatterns.length === 0 ? "." : includePatterns.length === 1 ? includePatterns[0] : `{${includePatterns.join(",")}}`,
};

function isNegatedGlob(glob: string) {
// https://github.com/micromatch/is-negated-glob/blob/master/index.js
return glob[0] === "!" && glob[1] !== "(";
}
}
7 changes: 5 additions & 2 deletions deno/common/ts_morph_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1247,12 +1247,15 @@ class InMemoryFileSystemHost {
const dir = this.directories.get(standardizedDirPath);
if (dir == null)
throw new errors.DirectoryNotFoundError(standardizedDirPath);
return [...getDirectories(this.directories.keys()), ...Array.from(dir.files.keys()).map(name => ({
return [
...getDirectories(this.directories.keys()),
...Array.from(dir.files.keys()).map(name => ({
name,
isDirectory: false,
isFile: true,
isSymlink: false,
}))];
})),
];
function* getDirectories(dirPaths) {
for (const path of dirPaths) {
const parentDir = FileUtils.getDirPath(path);
Expand Down

0 comments on commit cea07aa

Please sign in to comment.