1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-23 15:16:54 -05:00
Original: 47134db9f2
This commit is contained in:
Ryan Dahl 2019-05-21 02:44:36 -04:00 committed by GitHub
parent 16e52ee4b0
commit 7c4e973611
4 changed files with 13 additions and 10 deletions

View file

@ -1,5 +1,5 @@
variables: variables:
DENO_VERSION: "v0.5.0" DENO_VERSION: "v0.6.0"
TS_VERSION: "3.4.5" TS_VERSION: "3.4.5"
# TODO DRY up the jobs # TODO DRY up the jobs

View file

@ -145,7 +145,7 @@ async function copyDir(
const files = await Deno.readDir(src); const files = await Deno.readDir(src);
for (const file of files) { for (const file of files) {
const srcPath = file.path as string; const srcPath = path.join(src, file.name);
const destPath = path.join(dest, path.basename(srcPath as string)); const destPath = path.join(dest, path.basename(srcPath as string));
if (file.isDirectory()) { if (file.isDirectory()) {
await copyDir(srcPath, destPath, options); await copyDir(srcPath, destPath, options);
@ -173,7 +173,7 @@ function copyDirSync(src: string, dest: string, options: CopyOptions): void {
const files = Deno.readDirSync(src); const files = Deno.readDirSync(src);
for (const file of files) { for (const file of files) {
const srcPath = file.path as string; const srcPath = path.join(src, file.name);
const destPath = path.join(dest, path.basename(srcPath as string)); const destPath = path.join(dest, path.basename(srcPath as string));
if (file.isDirectory()) { if (file.isDirectory()) {
copyDirSync(srcPath, destPath, options); copyDirSync(srcPath, destPath, options);

View file

@ -16,8 +16,9 @@ export async function emptyDir(dir: string): Promise<void> {
} }
while (items.length) { while (items.length) {
const item = items.shift(); const item = items.shift();
if (item && item.path) { if (item && item.name) {
await Deno.remove(item.path, { recursive: true }); const fn = dir + "/" + item.name;
Deno.remove(fn, { recursive: true });
} }
} }
} }
@ -39,8 +40,9 @@ export function emptyDirSync(dir: string): void {
} }
while (items.length) { while (items.length) {
const item = items.shift(); const item = items.shift();
if (item && item.path) { if (item && item.name) {
Deno.removeSync(item.path, { recursive: true }); const fn = dir + "/" + item.name;
Deno.removeSync(fn, { recursive: true });
} }
} }
} }

View file

@ -149,19 +149,20 @@ async function serveDir(
const listEntry: string[] = []; const listEntry: string[] = [];
const fileInfos = await readDir(dirPath); const fileInfos = await readDir(dirPath);
for (const info of fileInfos) { for (const info of fileInfos) {
let fn = dirPath + "/" + info.name;
if (info.name === "index.html" && info.isFile()) { if (info.name === "index.html" && info.isFile()) {
// in case index.html as dir... // in case index.html as dir...
return await serveFile(req, info.path); return await serveFile(req, fn);
} }
// Yuck! // Yuck!
let mode = null; let mode = null;
try { try {
mode = (await stat(info.path)).mode; mode = (await stat(fn)).mode;
} catch (e) {} } catch (e) {}
listEntry.push( listEntry.push(
createDirEntryDisplay( createDirEntryDisplay(
info.name, info.name,
dirName + "/" + info.name, fn,
info.isFile() ? info.len : null, info.isFile() ? info.len : null,
mode, mode,
info.isDirectory() info.isDirectory()