Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
f7790c97
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f7790c97
编写于
8月 04, 2020
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unused deep merge code
上级
150d3786
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
4 addition
and
59 deletion
+4
-59
src/node/settings.ts
src/node/settings.ts
+4
-4
src/node/util.ts
src/node/util.ts
+0
-19
test/util.test.ts
test/util.test.ts
+0
-36
未找到文件。
src/node/settings.ts
浏览文件 @
f7790c97
import
*
as
fs
from
"
fs-extra
"
import
*
as
path
from
"
path
"
import
{
extend
,
paths
}
from
"
./util
"
import
{
paths
}
from
"
./util
"
import
{
logger
}
from
"
@coder/logger
"
import
{
Route
}
from
"
./http
"
...
...
@@ -30,12 +30,12 @@ export class SettingsProvider<T> {
/**
* Write settings combined with current settings. On failure log a warning.
* Settings
can be shallow or deep merged
.
* Settings
will be merged shallowly
.
*/
public
async
write
(
settings
:
Partial
<
T
>
,
shallow
=
true
):
Promise
<
void
>
{
public
async
write
(
settings
:
Partial
<
T
>
):
Promise
<
void
>
{
try
{
const
oldSettings
=
await
this
.
read
()
const
nextSettings
=
shallow
?
Object
.
assign
({},
oldSettings
,
settings
)
:
extend
(
oldSettings
,
settings
)
const
nextSettings
=
{
...
oldSettings
,
...
settings
}
await
fs
.
writeFile
(
this
.
settingsPath
,
JSON
.
stringify
(
nextSettings
,
null
,
2
))
}
catch
(
error
)
{
logger
.
warn
(
error
.
message
)
...
...
src/node/util.ts
浏览文件 @
f7790c97
...
...
@@ -199,25 +199,6 @@ export const isObject = <T extends object>(obj: T): obj is T => {
return
!
Array
.
isArray
(
obj
)
&&
typeof
obj
===
"
object
"
&&
obj
!==
null
}
/**
* Extend a with b and return a new object. Properties with objects will be
* recursively merged while all other properties are just overwritten.
*/
export
function
extend
<
A
,
B
>
(
a
:
A
,
b
:
B
):
A
&
B
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export
function
extend
(...
args
:
any
[]):
any
{
const
c
=
{}
as
any
// eslint-disable-line @typescript-eslint/no-explicit-any
for
(
const
obj
of
args
)
{
if
(
!
isObject
(
obj
))
{
continue
}
for
(
const
key
in
obj
)
{
c
[
key
]
=
isObject
(
obj
[
key
])
?
extend
(
c
[
key
],
obj
[
key
])
:
obj
[
key
]
}
}
return
c
}
/**
* Taken from vs/base/common/charCode.ts. Copied for now instead of importing so
* we don't have to set up a `vs` alias to be able to import with types (since
...
...
test/util.test.ts
浏览文件 @
f7790c97
import
*
as
assert
from
"
assert
"
import
{
normalize
}
from
"
../src/common/util
"
import
{
extend
}
from
"
../src/node/util
"
describe
(
"
util
"
,
()
=>
{
describe
(
"
extend
"
,
()
=>
{
it
(
"
should extend
"
,
()
=>
{
const
a
=
{
foo
:
{
bar
:
0
,
baz
:
2
},
garply
:
4
,
waldo
:
6
}
const
b
=
{
foo
:
{
bar
:
1
,
qux
:
3
},
garply
:
"
5
"
,
fred
:
7
}
const
extended
=
extend
(
a
,
b
)
assert
.
deepEqual
(
extended
,
{
foo
:
{
bar
:
1
,
baz
:
2
,
qux
:
3
},
garply
:
"
5
"
,
waldo
:
6
,
fred
:
7
,
})
})
it
(
"
should make deep copies of the original objects
"
,
()
=>
{
const
a
=
{
foo
:
0
,
bar
:
{
frobnozzle
:
2
},
mumble
:
{
qux
:
{
thud
:
4
}
}
}
const
b
=
{
foo
:
1
,
bar
:
{
chad
:
3
}
}
const
extended
=
extend
(
a
,
b
)
assert
.
notEqual
(
a
.
bar
,
extended
.
bar
)
assert
.
notEqual
(
b
.
bar
,
extended
.
bar
)
assert
.
notEqual
(
a
.
mumble
,
extended
.
mumble
)
assert
.
notEqual
(
a
.
mumble
.
qux
,
extended
.
mumble
.
qux
)
})
it
(
"
should handle mismatch in type
"
,
()
=>
{
const
a
=
{
foo
:
{
bar
:
0
,
baz
:
2
,
qux
:
{
mumble
:
11
}
},
garply
:
4
,
waldo
:
{
thud
:
10
}
}
const
b
=
{
foo
:
{
bar
:
[
1
],
baz
:
{
plugh
:
8
},
qux
:
12
},
garply
:
{
nox
:
9
},
waldo
:
7
}
const
extended
=
extend
(
a
,
b
)
assert
.
deepEqual
(
extended
,
{
foo
:
{
bar
:
[
1
],
baz
:
{
plugh
:
8
},
qux
:
12
},
garply
:
{
nox
:
9
},
waldo
:
7
,
})
})
})
describe
(
"
normalize
"
,
()
=>
{
it
(
"
should remove multiple slashes
"
,
()
=>
{
assert
.
equal
(
normalize
(
"
//foo//bar//baz///mumble
"
),
"
/foo/bar/baz/mumble
"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录