Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
437e35ca
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
437e35ca
编写于
4月 20, 2020
作者:
A
Ali Hasani
提交者:
GitHub
4月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add no-async-promise-executor lint rule (#4809)
上级
c1ec042a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
70 addition
and
109 deletion
+70
-109
.eslintrc.json
.eslintrc.json
+2
-1
std/node/_fs/_fs_appendFile.ts
std/node/_fs/_fs_appendFile.ts
+23
-26
std/node/_fs/_fs_chmod.ts
std/node/_fs/_fs_chmod.ts
+3
-14
std/node/_fs/_fs_chown.ts
std/node/_fs/_fs_chown.ts
+3
-14
std/node/_fs/_fs_copy.ts
std/node/_fs/_fs_copy.ts
+3
-14
std/node/_fs/_fs_dir.ts
std/node/_fs/_fs_dir.ts
+19
-18
std/node/_fs/_fs_exists.ts
std/node/_fs/_fs_exists.ts
+11
-13
std/node/_fs/_fs_mkdir.ts
std/node/_fs/_fs_mkdir.ts
+6
-9
未找到文件。
.eslintrc.json
浏览文件 @
437e35ca
...
...
@@ -23,7 +23,8 @@
"@typescript-eslint/ban-ts-ignore"
:
[
"off"
],
"@typescript-eslint/no-empty-function"
:
[
"off"
],
"no-return-await"
:
"error"
,
"require-await"
:
"error"
"require-await"
:
"error"
,
"no-async-promise-executor"
:
"error"
},
"overrides"
:
[
{
...
...
std/node/_fs/_fs_appendFile.ts
浏览文件 @
437e35ca
...
...
@@ -21,34 +21,31 @@ export function appendFile(
}
validateEncoding
(
options
);
let
rid
=
-
1
;
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
if
(
typeof
pathOrRid
===
"
number
"
)
{
rid
=
pathOrRid
;
}
else
{
const
mode
:
number
|
undefined
=
isFileOptions
(
options
)
?
options
.
mode
:
undefined
;
const
flag
:
string
|
undefined
=
isFileOptions
(
options
)
?
options
.
flag
:
undefined
;
if
(
mode
)
{
//TODO rework once https://github.com/denoland/deno/issues/4017 completes
notImplemented
(
"
Deno does not yet support setting mode on create
"
);
}
const
file
=
await
Deno
.
open
(
pathOrRid
,
getOpenOptions
(
flag
));
rid
=
file
.
rid
;
}
const
buffer
:
Uint8Array
=
new
TextEncoder
().
encode
(
data
);
const
buffer
:
Uint8Array
=
new
TextEncoder
().
encode
(
data
);
new
Promise
((
resolve
,
reject
)
=>
{
if
(
typeof
pathOrRid
===
"
number
"
)
{
rid
=
pathOrRid
;
Deno
.
write
(
rid
,
buffer
).
then
(
resolve
).
catch
(
reject
);
}
else
{
const
mode
:
number
|
undefined
=
isFileOptions
(
options
)
?
options
.
mode
:
undefined
;
const
flag
:
string
|
undefined
=
isFileOptions
(
options
)
?
options
.
flag
:
undefined
;
await
Deno
.
write
(
rid
,
buffer
);
resolve
();
}
catch
(
err
)
{
reject
(
err
);
if
(
mode
)
{
//TODO rework once https://github.com/denoland/deno/issues/4017 completes
notImplemented
(
"
Deno does not yet support setting mode on create
"
);
}
Deno
.
open
(
pathOrRid
,
getOpenOptions
(
flag
))
.
then
(({
rid
:
openedFileRid
})
=>
{
rid
=
openedFileRid
;
return
Deno
.
write
(
openedFileRid
,
buffer
);
})
.
then
(
resolve
)
.
catch
(
reject
);
}
})
.
then
(()
=>
{
...
...
std/node/_fs/_fs_chmod.ts
浏览文件 @
437e35ca
...
...
@@ -13,20 +13,9 @@ export function chmod(
mode
:
string
|
number
,
callback
:
CallbackWithError
):
void
{
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
await
Deno
.
chmod
(
path
,
getResolvedMode
(
mode
));
resolve
();
}
catch
(
err
)
{
reject
(
err
);
}
})
.
then
(()
=>
{
callback
();
})
.
catch
((
err
)
=>
{
callback
(
err
);
});
Deno
.
chmod
(
path
,
getResolvedMode
(
mode
))
.
then
(()
=>
callback
())
.
catch
(
callback
);
}
/**
...
...
std/node/_fs/_fs_chown.ts
浏览文件 @
437e35ca
...
...
@@ -12,20 +12,9 @@ export function chown(
gid
:
number
,
callback
:
CallbackWithError
):
void
{
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
await
Deno
.
chown
(
path
,
uid
,
gid
);
resolve
();
}
catch
(
err
)
{
reject
(
err
);
}
})
.
then
(()
=>
{
callback
();
})
.
catch
((
err
)
=>
{
callback
(
err
);
});
Deno
.
chown
(
path
,
uid
,
gid
)
.
then
(()
=>
callback
())
.
catch
(
callback
);
}
/**
...
...
std/node/_fs/_fs_copy.ts
浏览文件 @
437e35ca
...
...
@@ -7,20 +7,9 @@ export function copyFile(
destination
:
string
,
callback
:
CallbackWithError
):
void
{
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
await
Deno
.
copyFile
(
source
,
destination
);
resolve
();
}
catch
(
err
)
{
reject
(
err
);
}
})
.
then
(()
=>
{
callback
();
})
.
catch
((
err
)
=>
{
callback
(
err
);
});
Deno
.
copyFile
(
source
,
destination
)
.
then
(()
=>
callback
())
.
catch
(
callback
);
}
export
function
copyFileSync
(
source
:
string
,
destination
:
string
):
void
{
...
...
std/node/_fs/_fs_dir.ts
浏览文件 @
437e35ca
import
Dirent
from
"
./_fs_dirent.ts
"
;
import
{
assert
}
from
"
../../testing/asserts.ts
"
;
export
default
class
Dir
{
private
dirPath
:
string
|
Uint8Array
;
...
...
@@ -17,25 +18,25 @@ export default class Dir {
}
read
(
callback
?:
Function
):
Promise
<
Dirent
|
null
>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
if
(
!
this
.
asyncIterator
)
{
this
.
asyncIterator
=
Deno
.
readdir
(
this
.
path
)[
Symbol
.
asyncIterator
]();
}
const
result
:
Dirent
|
null
=
await
(
await
this
.
asyncIterator
?.
next
())
.
value
;
resolve
(
result
?
result
:
null
);
if
(
callback
)
{
callback
(
null
,
result
?
result
:
null
);
}
}
catch
(
err
)
{
if
(
callback
)
{
callback
(
err
,
null
);
}
reject
(
err
);
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
this
.
asyncIterator
)
{
this
.
asyncIterator
=
Deno
.
readdir
(
this
.
path
)[
Symbol
.
asyncIterator
]();
}
assert
(
this
.
asyncIterator
);
this
.
asyncIterator
.
next
()
.
then
(({
value
})
=>
{
resolve
(
value
?
value
:
null
);
if
(
callback
)
{
callback
(
null
,
value
?
value
:
null
);
}
})
.
catch
((
err
)
=>
{
if
(
callback
)
{
callback
(
err
,
null
);
}
reject
(
err
);
});
});
}
...
...
std/node/_fs/_fs_exists.ts
浏览文件 @
437e35ca
...
...
@@ -2,25 +2,23 @@
type
ExitsCallback
=
(
exists
:
boolean
)
=>
void
;
/* Deprecated in node api */
/**
* TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these
* are implemented. See https://github.com/denoland/deno/issues/3403
* Deprecated in node api
*/
export
function
exists
(
path
:
string
,
callback
:
ExitsCallback
):
void
{
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
await
Deno
.
lstat
(
path
);
resolve
();
}
catch
(
err
)
{
reject
(
err
);
}
})
Deno
.
lstat
(
path
)
.
then
(()
=>
{
callback
(
true
);
})
.
catch
(()
=>
{
callback
(
false
);
});
.
catch
(()
=>
callback
(
false
));
}
/**
* TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these
* are implemented. See https://github.com/denoland/deno/issues/3403
*/
export
function
existsSync
(
path
:
string
):
boolean
{
try
{
Deno
.
lstatSync
(
path
);
...
...
std/node/_fs/_fs_mkdir.ts
浏览文件 @
437e35ca
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import
{
CallbackWithError
}
from
"
./_fs_common.ts
"
;
type
Path
=
string
;
// TODO path can also be a Buffer or URL.
/**
* TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these
* are implemented. See https://github.com/denoland/deno/issues/3403
*/
type
Path
=
string
;
type
MkdirOptions
=
|
{
recursive
?:
boolean
;
mode
?:
number
|
undefined
}
|
number
...
...
@@ -29,14 +33,7 @@ export function mkdir(
throw
new
Deno
.
errors
.
InvalidData
(
"
invalid recursive option , must be a boolean
"
);
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
await
Deno
.
mkdir
(
path
,
{
recursive
,
mode
});
resolve
();
}
catch
(
err
)
{
reject
(
err
);
}
})
Deno
.
mkdir
(
path
,
{
recursive
,
mode
})
.
then
(()
=>
{
if
(
callback
&&
typeof
callback
==
"
function
"
)
{
callback
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录