FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
VSpaceCode/scripts/compile.js at vscode-vim · VSpaceCode/VSpaceCode · GitHub
VSpaceCode
/
VSpaceCode
Public
Notifications
You must be signed in to change notification settings
Fork
129
Star
1.5k
Code
Issues
66
Pull requests
13
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
VSpaceCode
/
scripts
/
compile.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
82 lines (72 loc) · 2.21 KB
Breadcrumbs
VSpaceCode
/
scripts
/
compile.js
Copy path
File metadata and controls
82 lines (72 loc) · 2.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const
fs
=
require
(
"fs-extra"
)
;
const
path
=
require
(
"path"
)
;
const
lodash
=
require
(
"lodash"
)
;
const
bigSetting
=
path
.
join
(
__dirname
,
".."
,
"./settings.json"
)
;
const
smallSetting
=
path
.
join
(
__dirname
,
"./settings.json"
)
;
const
keys
=
[
"vim.visualModeKeyBindings"
,
"vim.normalModeKeyBindings"
,
"vim.insertModeKeyBindings"
]
;
function
getBigKeyBinding
(
obj
)
{
const
result
=
[
]
;
for
(
const
key
in
obj
)
{
const
sub
=
{
before
:
key
.
split
(
" "
)
,
after
:
[
]
,
}
;
const
binding
=
obj
[
key
]
;
const
splited
=
binding
.
split
(
" "
)
;
const
type
=
splited
[
0
]
;
if
(
type
===
"after:"
)
{
sub
.
after
=
splited
.
slice
(
1
)
;
}
else
{
sub
.
commands
=
splited
.
slice
(
1
)
.
map
(
(
command
)
=>
(
{
command
,
args
:
[
]
}
)
)
;
}
result
.
push
(
sub
)
;
}
return
result
;
}
function
getBig
(
obj
)
{
const
result
=
lodash
.
omit
(
obj
,
keys
)
keys
.
forEach
(
(
key
)
=>
{
result
[
key
]
=
getBigKeyBinding
(
obj
[
key
]
)
;
}
)
;
return
result
;
}
function
getSmallKeyBinding
(
arr
)
{
const
result
=
{
}
;
for
(
const
keybinding
of
arr
)
{
const
key
=
keybinding
.
before
.
join
(
" "
)
;
let
binding
=
""
;
if
(
keybinding
.
after
&&
keybinding
.
after
.
length
)
{
binding
=
"after: "
+
keybinding
.
after
.
join
(
" "
)
;
}
else
{
binding
=
"commands: "
+
keybinding
.
commands
.
map
(
(
command
)
=>
command
.
command
)
.
join
(
" "
)
;
}
result
[
key
]
=
binding
;
}
return
result
;
}
function
getSmall
(
obj
)
{
const
result
=
lodash
.
omit
(
obj
,
keys
)
keys
.
forEach
(
(
key
)
=>
{
result
[
key
]
=
getSmallKeyBinding
(
obj
[
key
]
)
;
}
)
;
return
result
;
}
async
function
read
(
src
)
{
if
(
await
fs
.
exists
(
src
)
===
false
)
{
return
{
}
;
}
return
await
fs
.
readJson
(
src
)
;
}
async
function
write
(
src
,
obj
)
{
await
fs
.
writeFile
(
src
,
JSON
.
stringify
(
obj
,
null
,
4
)
+
"\n"
)
;
}
async
function
syncSettings
(
)
{
const
settings
=
getSmall
(
await
read
(
bigSetting
)
)
;
const
smallSettings
=
await
read
(
smallSetting
)
;
if
(
lodash
.
isEqual
(
smallSettings
,
{
}
)
)
{
await
write
(
smallSetting
,
settings
)
;
}
else
{
await
write
(
bigSetting
,
getBig
(
smallSettings
)
)
;
}
}
syncSettings
(
)
.
catch
(
console
.
log
)
;
Back
|
FazBrowse Home
|
New Git URL