|
|
@ -180,12 +180,34 @@ export class RemixdClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
|
|
if (!fs.existsSync(path)) return reject(new Error('File not found ' + path)) |
|
|
|
if (!fs.existsSync(path)) return reject(new Error('File not found ' + path)) |
|
|
|
if (!isRealPath(path)) return |
|
|
|
if (!isRealPath(path)) return |
|
|
|
|
|
|
|
// Saving the content of the item{folder} before removing it
|
|
|
|
|
|
|
|
const ls = [] |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const resolveList = (path) => { |
|
|
|
|
|
|
|
if (!this._isFile(path)) { |
|
|
|
|
|
|
|
const list = utils.resolveDirectory(path, this.currentSharedFolder) |
|
|
|
|
|
|
|
Object.keys(list).forEach(itemPath => { |
|
|
|
|
|
|
|
if (list[itemPath].isDirectory) { |
|
|
|
|
|
|
|
resolveList(`${this.currentSharedFolder}/${itemPath}`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ls.push(itemPath) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
resolveList(path) |
|
|
|
|
|
|
|
ls.push(args.path) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
throw new Error(e) |
|
|
|
|
|
|
|
} |
|
|
|
return fs.remove(path, (error: Error) => { |
|
|
|
return fs.remove(path, (error: Error) => { |
|
|
|
if (error) { |
|
|
|
if (error) { |
|
|
|
console.log(error) |
|
|
|
console.log(error) |
|
|
|
return reject(new Error('Failed to remove file/directory: ' + error)) |
|
|
|
return reject(new Error('Failed to remove file/directory: ' + error)) |
|
|
|
} |
|
|
|
} |
|
|
|
this.emit('fileRemoved', args.path) |
|
|
|
for (const file in ls) { |
|
|
|
|
|
|
|
this.emit('fileRemoved', ls[file]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resolve(true) |
|
|
|
resolve(true) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -194,10 +216,17 @@ export class RemixdClient extends PluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_isFile (path: string): boolean { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
return fs.statSync(path).isFile() |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
throw new Error(error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isDirectory (args: SharedFolderArgs): boolean { |
|
|
|
isDirectory (args: SharedFolderArgs): boolean { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const path = utils.absolutePath(args.path, this.currentSharedFolder) |
|
|
|
const path = utils.absolutePath(args.path, this.currentSharedFolder) |
|
|
|
|
|
|
|
|
|
|
|
return fs.statSync(path).isDirectory() |
|
|
|
return fs.statSync(path).isDirectory() |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
throw new Error(error) |
|
|
|
throw new Error(error) |
|
|
@ -207,7 +236,6 @@ export class RemixdClient extends PluginClient { |
|
|
|
isFile (args: SharedFolderArgs): boolean { |
|
|
|
isFile (args: SharedFolderArgs): boolean { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const path = utils.absolutePath(args.path, this.currentSharedFolder) |
|
|
|
const path = utils.absolutePath(args.path, this.currentSharedFolder) |
|
|
|
|
|
|
|
|
|
|
|
return fs.statSync(path).isFile() |
|
|
|
return fs.statSync(path).isFile() |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
throw new Error(error) |
|
|
|
throw new Error(error) |
|
|
|