fs-extra#readdirSync TypeScript Examples
The following examples show how to use
fs-extra#readdirSync.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From nestjs-proto-gen-ts with MIT License | 6 votes |
private getProtoFiles(pkg: string): void {
if (!existsSync(pkg)) {
throw new Error(`Directory ${pkg} is not exist`);
}
const files = readdirSync(pkg);
for (let i = 0; i < files.length; i++) {
const filename = join(pkg, files[i]);
const stat = lstatSync(filename);
if (filename.indexOf(this.options.ignore.join()) > -1) {
continue;
}
if (stat.isDirectory()) {
this.getProtoFiles(filename);
} else if (filename.indexOf(this.options.target.join()) > -1) {
this.generate(filename, pkg);
}
}
}
Example #2
Source File: code-loader.ts From malagu with MIT License | 6 votes |
protected async doLoad(codeDir: string, zip: JSZip, codeUri?: CodeUri) {
const files = readdirSync(codeDir);
for (const fileName of files) {
const fullPath = join(codeDir, fileName);
if (!codeUri?.include || !this.match(codeUri.include, fullPath)) {
if (codeUri?.exclude && this.match(codeUri.exclude, fullPath)) {
continue;
}
}
const file = statSync(fullPath);
if (file.isDirectory()) {
const dir = zip.folder(fileName);
if (dir) {
await this.doLoad(fullPath, dir, codeUri);
}
} else {
zip.file(fileName, readFileSync(fullPath), {
unixPermissions: '755'
});
}
}
}
Example #3
Source File: file.ts From cli with Apache License 2.0 | 6 votes |
export function foldersContainSimilarFiles(folder1: string, folder2: string) {
const folder1Files = readdirSync(folder1);
const folder2Files = readdirSync(folder2);
if (folder1Files.length !== folder2Files.length) {
return false;
}
for (const file of folder1Files) {
if (!existsSync(join(folder2, file))) {
return false;
}
}
return true;
}
Example #4
Source File: RestoreVault.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
async gatherInputs(): Promise<any> {
const snapshots = path.join(getDWorkspace().wsRoot as string, "snapshots");
const choices = readdirSync(snapshots)
.sort()
.map((ent) => ({
label: `${Time.DateTime.fromMillis(parseInt(ent, 10)).toLocaleString(
Time.DateTime.DATETIME_FULL
)} (${ent})`,
data: ent,
}));
return VSCodeUtils.showQuickPick(choices);
}
Example #5
Source File: main.ts From DefinitelyTyped-tools with MIT License | 6 votes |
function logPerformance() {
const big: [string, number][] = [];
const types: number[] = [];
if (existsSync(perfDir)) {
console.log("\n\n=== PERFORMANCE ===\n");
for (const filename of readdirSync(perfDir, { encoding: "utf8" })) {
const x = JSON.parse(readFileSync(joinPaths(perfDir, filename), { encoding: "utf8" })) as {
[s: string]: { typeCount: number; memory: number };
};
for (const k of Object.keys(x)) {
big.push([k, x[k].typeCount]);
types.push(x[k].typeCount);
}
}
console.log(
"{" +
big
.sort((a, b) => b[1] - a[1])
.map(([name, count]) => ` "${name}": ${count}`)
.join(",") +
"}"
);
console.log(" * Percentiles: ");
console.log("99:", percentile(types, 0.99));
console.log("95:", percentile(types, 0.95));
console.log("90:", percentile(types, 0.9));
console.log("70:", percentile(types, 0.7));
console.log("50:", percentile(types, 0.5));
}
}
Example #6
Source File: fixturedActions.test.ts From dt-mergebot with MIT License | 5 votes |
describe("Test fixtures", () => {
const fixturesFolder = join(__dirname, "fixtures");
readdirSync(fixturesFolder, { withFileTypes: true }).forEach(dirent => {
if (dirent.isDirectory()) {
it(`Fixture: ${dirent.name}`, async () => testFixture(join(fixturesFolder, dirent.name)));
}
});
});
Example #7
Source File: fs.ts From DefinitelyTyped-tools with MIT License | 5 votes |
readdir(dirPath?: string): readonly string[] {
return readdirSync(this.getPath(dirPath))
.sort()
.filter((name) => name !== ".DS_Store");
}
Example #8
Source File: index.ts From nx-dotnet with MIT License | 5 votes |
export function listFiles(dirName: string) {
return readdirSync(tmpProjPath(dirName));
}