mirror of
https://github.com/denoland/deno.git
synced 2024-10-31 09:14:20 -04:00
d43b43ca78
Instead of using core/snapshot_creator.rs, instead two crates are introduced which allow building the snapshot during build.rs. Rollup is removed and replaced with our own bundler. This removes the Node build dependency. Modules in //js now use Deno-style imports with file extensions, rather than Node style extensionless imports. This improves incremental build time when changes are made to //js files by about 40 seconds.
34 lines
1 KiB
TypeScript
34 lines
1 KiB
TypeScript
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
|
import * as dispatch from "./dispatch.ts";
|
|
import { FileInfo, FileInfoImpl } from "./file_info.ts";
|
|
import { StatResponse } from "./stat.ts";
|
|
|
|
interface ReadDirResponse {
|
|
entries: StatResponse[];
|
|
}
|
|
|
|
function res(response: ReadDirResponse): FileInfo[] {
|
|
return response.entries.map(
|
|
(statRes: StatResponse): FileInfo => {
|
|
return new FileInfoImpl(statRes);
|
|
}
|
|
);
|
|
}
|
|
|
|
/** Reads the directory given by path and returns a list of file info
|
|
* synchronously.
|
|
*
|
|
* const files = Deno.readDirSync("/");
|
|
*/
|
|
export function readDirSync(path: string): FileInfo[] {
|
|
return res(sendSync(dispatch.OP_READ_DIR, { path }));
|
|
}
|
|
|
|
/** Reads the directory given by path and returns a list of file info.
|
|
*
|
|
* const files = await Deno.readDir("/");
|
|
*/
|
|
export async function readDir(path: string): Promise<FileInfo[]> {
|
|
return res(await sendAsync(dispatch.OP_READ_DIR, { path }));
|
|
}
|