Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
0354e21c
Commit
0354e21c
authored
Jun 19, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trigger fileAdded, fileChanged and fileRemoved event
parent
ec9c4748
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
remixdClient.ts
src/services/remixdClient.ts
+13
-5
utils.ts
src/utils.ts
+1
-3
No files found.
src/services/remixdClient.ts
View file @
0354e21c
...
...
@@ -86,8 +86,9 @@ export class RemixdClient extends PluginClient {
if
(
this
.
readOnly
)
reject
(
'Cannot write file: read-only mode selected'
)
const
isFolder
=
args
.
path
.
endsWith
(
'/'
)
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
const
exists
=
fs
.
existsSync
(
path
)
if
(
fs
.
existsSync
(
path
)
&&
!
isRealPath
(
path
))
reject
()
if
(
exists
&&
!
isRealPath
(
path
))
reject
()
if
(
args
.
content
===
'undefined'
)
{
// no !!!!!
console
.
log
(
'trying to write "undefined" ! stopping.'
)
reject
(
'trying to write "undefined" ! stopping.'
)
...
...
@@ -95,11 +96,12 @@ export class RemixdClient extends PluginClient {
this
.
trackDownStreamUpdate
[
path
]
=
path
if
(
isFolder
)
{
fs
.
mkdirp
(
path
).
then
(()
=>
{
const
splitPath
=
path
.
split
(
'/'
)
splitPath
.
pop
()
const
parentDir
=
splitPath
.
join
(
'/'
)
+
'/'
let
splitPath
=
args
.
path
.
split
(
'/'
)
splitPath
=
splitPath
.
filter
(
dir
=>
dir
)
const
dir
=
'/'
+
splitPath
.
join
(
'/'
)
this
.
emit
(
'folderAdded'
,
parentD
ir
)
this
.
emit
(
'folderAdded'
,
d
ir
)
resolve
()
}).
catch
((
e
:
Error
)
=>
reject
(
e
))
}
else
{
...
...
@@ -112,6 +114,11 @@ export class RemixdClient extends PluginClient {
resolve
()
})
}).
catch
((
e
:
Error
)
=>
reject
(
e
))
if
(
!
exists
)
{
this
.
emit
(
'fileAdded'
,
args
.
path
)
}
else
{
this
.
emit
(
'fileChanged'
,
args
.
path
)
}
}
})
}
catch
(
error
)
{
...
...
@@ -157,6 +164,7 @@ export class RemixdClient extends PluginClient {
console
.
log
(
error
)
reject
(
'Failed to remove file/directory: '
+
error
)
}
this
.
emit
(
'fileRemoved'
,
args
.
path
)
resolve
(
true
)
})
})
...
...
src/utils.ts
View file @
0354e21c
...
...
@@ -14,9 +14,7 @@ const pathModule = require('path')
*/
function
absolutePath
(
path
:
string
,
sharedFolder
:
string
):
string
{
path
=
normalizePath
(
path
)
const
exists
=
fs
.
existsSync
(
'/'
+
path
)
if
(
!
exists
&&
path
.
indexOf
(
sharedFolder
)
!==
0
)
{
if
(
path
.
indexOf
(
sharedFolder
)
!==
0
)
{
path
=
pathModule
.
resolve
(
sharedFolder
,
path
)
}
return
path
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment