Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
9a63902d
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9a63902d
编写于
3月 06, 2020
作者:
D
dubiousjim
提交者:
GitHub
3月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename readDir -> readdir (#4225)
上级
afea9b2e
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
46 addition
and
47 deletion
+46
-47
cli/js/deno.ts
cli/js/deno.ts
+1
-1
cli/js/file_info.ts
cli/js/file_info.ts
+2
-2
cli/js/lib.deno.ns.d.ts
cli/js/lib.deno.ns.d.ts
+9
-10
cli/js/read_dir.ts
cli/js/read_dir.ts
+4
-4
cli/js/read_dir_test.ts
cli/js/read_dir_test.ts
+12
-12
cli/js/test_util.ts
cli/js/test_util.ts
+1
-1
std/fs/copy.ts
std/fs/copy.ts
+2
-2
std/fs/empty_dir.ts
std/fs/empty_dir.ts
+3
-3
std/fs/walk.ts
std/fs/walk.ts
+3
-3
std/http/file_server.ts
std/http/file_server.ts
+3
-3
std/node/_fs_dir.ts
std/node/_fs_dir.ts
+2
-2
tools/testdata/unit_test_output1.txt
tools/testdata/unit_test_output1.txt
+2
-2
tools/testdata/unit_test_output3.txt
tools/testdata/unit_test_output3.txt
+2
-2
未找到文件。
cli/js/deno.ts
浏览文件 @
9a63902d
...
...
@@ -111,7 +111,7 @@ export {
ProcessStatus
,
Signal
}
from
"
./process.ts
"
;
export
{
read
DirSync
,
readD
ir
}
from
"
./read_dir.ts
"
;
export
{
read
dirSync
,
readd
ir
}
from
"
./read_dir.ts
"
;
export
{
readFileSync
,
readFile
}
from
"
./read_file.ts
"
;
export
{
readlinkSync
,
readlink
}
from
"
./read_link.ts
"
;
export
{
realpathSync
,
realpath
}
from
"
./realpath.ts
"
;
...
...
cli/js/file_info.ts
浏览文件 @
9a63902d
...
...
@@ -3,8 +3,8 @@ import { StatResponse } from "./stat.ts";
import
{
build
}
from
"
./build.ts
"
;
/** A FileInfo describes a file and is returned by `stat`, `lstat`,
* `statSync`, `lstatSync`. A list of FileInfo is returned by `read
D
ir`,
* `read
D
irSync`. */
* `statSync`, `lstatSync`. A list of FileInfo is returned by `read
d
ir`,
* `read
d
irSync`. */
export
interface
FileInfo
{
/** The size of the file, in bytes. */
len
:
number
;
...
...
cli/js/lib.deno.ns.d.ts
浏览文件 @
9a63902d
...
...
@@ -992,8 +992,8 @@ declare namespace Deno {
/** UNSTABLE: 'len' maybe should be 'length' or 'size'.
*
* A FileInfo describes a file and is returned by `stat`, `lstat`,
* `statSync`, `lstatSync`. A list of FileInfo is returned by `read
D
ir`,
* `read
D
irSync`. */
* `statSync`, `lstatSync`. A list of FileInfo is returned by `read
d
ir`,
* `read
d
irSync`. */
export
interface
FileInfo
{
/** **UNSTABLE**: `.len` maybe should be `.length` or `.size`.
*
...
...
@@ -1079,25 +1079,24 @@ declare namespace Deno {
// @url js/read_dir.d.ts
/** UNSTABLE:
Unstable rename to readdirSync.
/** UNSTABLE:
need to consider streaming case
*
/
* Synchronously reads the directory given by `path` and returns an array of
* Synchronously reads the directory given by `path` and returns an array of
* `Deno.FileInfo`.
*
* const files = Deno.read
D
irSync("/");
* const files = Deno.read
d
irSync("/");
*
* Requires `allow-read` permission. */
export
function
read
D
irSync
(
path
:
string
):
FileInfo
[];
export
function
read
d
irSync
(
path
:
string
):
FileInfo
[];
/** UNSTABLE: Possibly rename to `.readdir()`. Maybe need to return an
* `AsyncIterable`.
/** UNSTABLE: Maybe need to return an `AsyncIterable`.
*
* Reads the directory given by `path` and resolves to an array of `Deno.FileInfo`.
*
* const files = await Deno.read
D
ir("/");
* const files = await Deno.read
d
ir("/");
*
* Requires `allow-read` permission. */
export
function
read
D
ir
(
path
:
string
):
Promise
<
FileInfo
[]
>
;
export
function
read
d
ir
(
path
:
string
):
Promise
<
FileInfo
[]
>
;
// @url js/copy_file.d.ts
...
...
cli/js/read_dir.ts
浏览文件 @
9a63902d
...
...
@@ -18,10 +18,10 @@ function res(response: ReadDirResponse): FileInfo[] {
/** Synchronously reads the directory given by `path` and returns an array of
* `Deno.FileInfo`.
*
* const files = Deno.read
D
irSync("/");
* const files = Deno.read
d
irSync("/");
*
* Requires `allow-read` permission. */
export
function
read
D
irSync
(
path
:
string
):
FileInfo
[]
{
export
function
read
d
irSync
(
path
:
string
):
FileInfo
[]
{
return
res
(
sendSync
(
"
op_read_dir
"
,
{
path
}));
}
...
...
@@ -29,9 +29,9 @@ export function readDirSync(path: string): FileInfo[] {
*
* Reads the directory given by `path` and resolves to an array of `Deno.FileInfo`.
*
* const files = await Deno.read
D
ir("/");
* const files = await Deno.read
d
ir("/");
*
* Requires `allow-read` permission. */
export
async
function
read
D
ir
(
path
:
string
):
Promise
<
FileInfo
[]
>
{
export
async
function
read
d
ir
(
path
:
string
):
Promise
<
FileInfo
[]
>
{
return
res
(
await
sendAsync
(
"
op_read_dir
"
,
{
path
}));
}
cli/js/read_dir_test.ts
浏览文件 @
9a63902d
...
...
@@ -21,15 +21,15 @@ function assertSameContent(files: FileInfo[]): void {
assertEquals
(
counter
,
2
);
}
unitTest
({
perms
:
{
read
:
true
}
},
function
read
D
irSyncSuccess
():
void
{
const
files
=
Deno
.
read
D
irSync
(
"
cli/tests/
"
);
unitTest
({
perms
:
{
read
:
true
}
},
function
read
d
irSyncSuccess
():
void
{
const
files
=
Deno
.
read
d
irSync
(
"
cli/tests/
"
);
assertSameContent
(
files
);
});
unitTest
({
perms
:
{
read
:
false
}
},
function
read
D
irSyncPerm
():
void
{
unitTest
({
perms
:
{
read
:
false
}
},
function
read
d
irSyncPerm
():
void
{
let
caughtError
=
false
;
try
{
Deno
.
read
D
irSync
(
"
tests/
"
);
Deno
.
read
d
irSync
(
"
tests/
"
);
}
catch
(
e
)
{
caughtError
=
true
;
assert
(
e
instanceof
Deno
.
errors
.
PermissionDenied
);
...
...
@@ -37,12 +37,12 @@ unitTest({ perms: { read: false } }, function readDirSyncPerm(): void {
assert
(
caughtError
);
});
unitTest
({
perms
:
{
read
:
true
}
},
function
read
D
irSyncNotDir
():
void
{
unitTest
({
perms
:
{
read
:
true
}
},
function
read
d
irSyncNotDir
():
void
{
let
caughtError
=
false
;
let
src
;
try
{
src
=
Deno
.
read
D
irSync
(
"
cli/tests/fixture.json
"
);
src
=
Deno
.
read
d
irSync
(
"
cli/tests/fixture.json
"
);
}
catch
(
err
)
{
caughtError
=
true
;
assert
(
err
instanceof
Error
);
...
...
@@ -51,12 +51,12 @@ unitTest({ perms: { read: true } }, function readDirSyncNotDir(): void {
assertEquals
(
src
,
undefined
);
});
unitTest
({
perms
:
{
read
:
true
}
},
function
read
D
irSyncNotFound
():
void
{
unitTest
({
perms
:
{
read
:
true
}
},
function
read
d
irSyncNotFound
():
void
{
let
caughtError
=
false
;
let
src
;
try
{
src
=
Deno
.
read
D
irSync
(
"
bad_dir_name
"
);
src
=
Deno
.
read
d
irSync
(
"
bad_dir_name
"
);
}
catch
(
err
)
{
caughtError
=
true
;
assert
(
err
instanceof
Deno
.
errors
.
NotFound
);
...
...
@@ -65,19 +65,19 @@ unitTest({ perms: { read: true } }, function readDirSyncNotFound(): void {
assertEquals
(
src
,
undefined
);
});
unitTest
({
perms
:
{
read
:
true
}
},
async
function
read
D
irSuccess
():
Promise
<
unitTest
({
perms
:
{
read
:
true
}
},
async
function
read
d
irSuccess
():
Promise
<
void
>
{
const
files
=
await
Deno
.
read
D
ir
(
"
cli/tests/
"
);
const
files
=
await
Deno
.
read
d
ir
(
"
cli/tests/
"
);
assertSameContent
(
files
);
});
unitTest
({
perms
:
{
read
:
false
}
},
async
function
read
D
irPerm
():
Promise
<
unitTest
({
perms
:
{
read
:
false
}
},
async
function
read
d
irPerm
():
Promise
<
void
>
{
let
caughtError
=
false
;
try
{
await
Deno
.
read
D
ir
(
"
tests/
"
);
await
Deno
.
read
d
ir
(
"
tests/
"
);
}
catch
(
e
)
{
caughtError
=
true
;
assert
(
e
instanceof
Deno
.
errors
.
PermissionDenied
);
...
...
cli/js/test_util.ts
浏览文件 @
9a63902d
...
...
@@ -385,7 +385,7 @@ unitTest(
unitTest
(
{
perms
:
{
read
:
true
}
},
async
function
assertAllUnitTestFilesImported
():
Promise
<
void
>
{
const
directoryTestFiles
=
Deno
.
read
D
irSync
(
"
./cli/js
"
)
const
directoryTestFiles
=
Deno
.
read
d
irSync
(
"
./cli/js
"
)
.
map
(
k
=>
k
.
name
)
.
filter
(
file
=>
file
!
.
endsWith
(
"
_test.ts
"
));
const
unitTestsFile
:
Uint8Array
=
Deno
.
readFileSync
(
...
...
std/fs/copy.ts
浏览文件 @
9a63902d
...
...
@@ -157,7 +157,7 @@ async function copyDir(
await
Deno
.
utime
(
dest
,
srcStatInfo
.
accessed
,
srcStatInfo
.
modified
);
}
const
files
=
await
Deno
.
read
D
ir
(
src
);
const
files
=
await
Deno
.
read
d
ir
(
src
);
for
(
const
file
of
files
)
{
assert
(
file
.
name
!=
null
,
"
file.name must be set
"
);
...
...
@@ -188,7 +188,7 @@ function copyDirSync(src: string, dest: string, options: CopyOptions): void {
Deno
.
utimeSync
(
dest
,
srcStatInfo
.
accessed
,
srcStatInfo
.
modified
);
}
const
files
=
Deno
.
read
D
irSync
(
src
);
const
files
=
Deno
.
read
d
irSync
(
src
);
for
(
const
file
of
files
)
{
assert
(
file
.
name
!=
null
,
"
file.name must be set
"
);
...
...
std/fs/empty_dir.ts
浏览文件 @
9a63902d
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import
{
join
}
from
"
../path/mod.ts
"
;
const
{
read
Dir
,
readD
irSync
,
mkdir
,
mkdirSync
,
remove
,
removeSync
}
=
Deno
;
const
{
read
dir
,
readd
irSync
,
mkdir
,
mkdirSync
,
remove
,
removeSync
}
=
Deno
;
/**
* Ensures that a directory is empty.
* Deletes directory contents if the directory is not empty.
...
...
@@ -10,7 +10,7 @@ const { readDir, readDirSync, mkdir, mkdirSync, remove, removeSync } = Deno;
*/
export
async
function
emptyDir
(
dir
:
string
):
Promise
<
void
>
{
try
{
const
items
=
await
read
D
ir
(
dir
);
const
items
=
await
read
d
ir
(
dir
);
while
(
items
.
length
)
{
const
item
=
items
.
shift
();
...
...
@@ -38,7 +38,7 @@ export async function emptyDir(dir: string): Promise<void> {
*/
export
function
emptyDirSync
(
dir
:
string
):
void
{
try
{
const
items
=
read
D
irSync
(
dir
);
const
items
=
read
d
irSync
(
dir
);
// if directory already exist. then remove it's child item.
while
(
items
.
length
)
{
...
...
std/fs/walk.ts
浏览文件 @
9a63902d
...
...
@@ -3,7 +3,7 @@
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
import
{
unimplemented
,
assert
}
from
"
../testing/asserts.ts
"
;
import
{
join
}
from
"
../path/mod.ts
"
;
const
{
read
Dir
,
readD
irSync
,
stat
,
statSync
}
=
Deno
;
const
{
read
dir
,
readd
irSync
,
stat
,
statSync
}
=
Deno
;
type
FileInfo
=
Deno
.
FileInfo
;
export
interface
WalkOptions
{
...
...
@@ -79,7 +79,7 @@ export async function* walk(
if
(
maxDepth
<
1
||
!
include
(
root
,
undefined
,
undefined
,
skip
))
{
return
;
}
const
ls
:
FileInfo
[]
=
await
read
D
ir
(
root
);
const
ls
:
FileInfo
[]
=
await
read
d
ir
(
root
);
for
(
const
info
of
ls
)
{
if
(
info
.
isSymlink
())
{
if
(
followSymlinks
)
{
...
...
@@ -133,7 +133,7 @@ export function* walkSync(
if
(
maxDepth
<
1
||
!
include
(
root
,
undefined
,
undefined
,
skip
))
{
return
;
}
const
ls
:
FileInfo
[]
=
read
D
irSync
(
root
);
const
ls
:
FileInfo
[]
=
read
d
irSync
(
root
);
for
(
const
info
of
ls
)
{
if
(
info
.
isSymlink
())
{
if
(
followSymlinks
)
{
...
...
std/http/file_server.ts
浏览文件 @
9a63902d
...
...
@@ -6,7 +6,7 @@
// TODO Add tests like these:
// https://github.com/indexzero/http-server/blob/master/test/http-server-test.js
const
{
args
,
stat
,
read
D
ir
,
open
,
exit
}
=
Deno
;
const
{
args
,
stat
,
read
d
ir
,
open
,
exit
}
=
Deno
;
import
{
posix
}
from
"
../path/mod.ts
"
;
import
{
listenAndServe
,
ServerRequest
,
Response
}
from
"
./server.ts
"
;
import
{
parse
}
from
"
../flags/mod.ts
"
;
...
...
@@ -113,14 +113,14 @@ async function serveFile(
return
res
;
}
// TODO: simplify this after deno.stat and deno.read
D
ir are fixed
// TODO: simplify this after deno.stat and deno.read
d
ir are fixed
async
function
serveDir
(
req
:
ServerRequest
,
dirPath
:
string
):
Promise
<
Response
>
{
const
dirUrl
=
`/
${
posix
.
relative
(
target
,
dirPath
)}
`
;
const
listEntry
:
EntryInfo
[]
=
[];
const
fileInfos
=
await
read
D
ir
(
dirPath
);
const
fileInfos
=
await
read
d
ir
(
dirPath
);
for
(
const
fileInfo
of
fileInfos
)
{
const
filePath
=
posix
.
join
(
dirPath
,
fileInfo
.
name
??
""
);
const
fileUrl
=
posix
.
join
(
dirUrl
,
fileInfo
.
name
??
""
);
...
...
std/node/_fs_dir.ts
浏览文件 @
9a63902d
...
...
@@ -29,7 +29,7 @@ export default class Dir {
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
if
(
this
.
initializationOfDirectoryFilesIsRequired
())
{
const
denoFiles
:
Deno
.
FileInfo
[]
=
await
Deno
.
read
D
ir
(
this
.
path
);
const
denoFiles
:
Deno
.
FileInfo
[]
=
await
Deno
.
read
d
ir
(
this
.
path
);
this
.
files
=
denoFiles
.
map
(
file
=>
new
Dirent
(
file
));
}
const
nextFile
=
this
.
files
.
pop
();
...
...
@@ -55,7 +55,7 @@ export default class Dir {
readSync
():
Dirent
|
null
{
if
(
this
.
initializationOfDirectoryFilesIsRequired
())
{
this
.
files
.
push
(
...
Deno
.
read
D
irSync
(
this
.
path
).
map
(
file
=>
new
Dirent
(
file
))
...
Deno
.
read
d
irSync
(
this
.
path
).
map
(
file
=>
new
Dirent
(
file
))
);
}
const
dirent
:
Dirent
|
undefined
=
this
.
files
.
pop
();
...
...
tools/testdata/unit_test_output1.txt
浏览文件 @
9a63902d
...
...
@@ -133,9 +133,9 @@ test readFileSyncNotFound_permW0N0E0
... [32mok[0m
test readFileSuccess_permW0N0E0
... [32mok[0m
test read
D
irSyncNotDir_permW0N0E0
test read
d
irSyncNotDir_permW0N0E0
... [32mok[0m
test read
D
irSyncNotFound_permW0N0E0
test read
d
irSyncNotFound_permW0N0E0
... [32mok[0m
test writeFileSyncPerm_permW0N0E0
... [32mok[0m
...
...
tools/testdata/unit_test_output3.txt
浏览文件 @
9a63902d
...
...
@@ -163,9 +163,9 @@ test readFileSyncNotFound_permW0N0E0
... [32mok[0m
test readFileSuccess_permW0N0E0
... [32mok[0m
test read
D
irSyncNotDir_permW0N0E0
test read
d
irSyncNotDir_permW0N0E0
... [32mok[0m
test read
D
irSyncNotFound_permW0N0E0
test read
d
irSyncNotFound_permW0N0E0
... [32mok[0m
test writeFileSyncPerm_permW0N0E0
... [32mok[0m
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录