Emit folder added event from plugin

pull/3094/head
ioedeveloper 5 years ago
parent fa675e6d14
commit f16c21a03f
  1. 2
      package.json
  2. 9
      src/services/remixdClient.ts
  3. 4
      src/utils.ts

@ -8,7 +8,7 @@
},
"scripts": {
"test": "echo \"Error: no test specified\"",
"start": "./lib/bin/remixd.js",
"start": "./lib/bin/remixd.js -s ./shared --remix-ide http://127.0.0.1:8080",
"npip": "npip",
"lint": "eslint ./src --ext .ts",
"build": "tsc -p ./ && chmod +x ./lib/bin/remixd.js",

@ -94,7 +94,14 @@ export class RemixdClient extends PluginClient {
}
this.trackDownStreamUpdate[path] = path
if (isFolder) {
fs.mkdirp(path).then(() => resolve()).catch((e: Error) => reject(e))
fs.mkdirp(path).then(() => {
const splitPath = path.split('/')
splitPath.pop()
const parentDir = splitPath.join('/') + '/'
this.emit('folderAdded', parentDir)
resolve()
}).catch((e: Error) => reject(e))
} else {
fs.ensureFile(path).then(() => {
fs.writeFile(path, args.content, 'utf8', (error: Error) => {

@ -14,7 +14,9 @@ const pathModule = require('path')
*/
function absolutePath (path: string, sharedFolder:string): string {
path = normalizePath(path)
if (path.indexOf(sharedFolder) !== 0) {
const exists = fs.existsSync('/' + path)
if (!exists && path.indexOf(sharedFolder) !== 0) {
path = pathModule.resolve(sharedFolder, path)
}
return path

Loading…
Cancel
Save