Move isSubDirectory function to fileProvider class.

pull/2195/head
David Disu 3 years ago committed by yann300
parent 72c16efa06
commit 89d35a2023
  1. 9
      apps/remix-ide/src/app/files/fileProvider.js
  2. 9
      apps/remix-ide/src/app/files/remixDProvider.js
  3. 8
      apps/remix-ide/src/app/files/workspaceFileProvider.js

@ -3,6 +3,7 @@
import { CompilerImports } from '@remix-project/core-plugin'
const EventManager = require('events')
const remixLib = require('@remix-project/remix-lib')
const pathModule = require('path')
const Storage = remixLib.Storage
class FileProvider {
@ -308,6 +309,14 @@ class FileProvider {
_normalizePath (path) {
return this.type + path
}
isSubDirectory (parent, child) {
if (!parent) return false
if (parent === child) return true
const relative = pathModule.relative(parent, child)
return !!relative && relative.split(pathModule.sep)[0] !== '..'
}
}
module.exports = FileProvider

@ -1,6 +1,5 @@
'use strict'
const FileProvider = require('./fileProvider')
const pathModule = require('path')
module.exports = class RemixDProvider extends FileProvider {
constructor (appManager) {
@ -208,12 +207,4 @@ module.exports = class RemixDProvider extends FileProvider {
if (!this._isReady) throw new Error('provider not ready')
return await this._appManager.call('remixd', 'isFile', { path: unprefixedpath })
}
isSubDirectory (parent, child) {
if (!parent) return false
if (parent === child) return true
const relative = pathModule.relative(parent, child)
return !!relative && relative.split(pathModule.sep)[0] !== '..'
}
}

@ -49,14 +49,6 @@ class WorkspaceFileProvider extends FileProvider {
return ret
}
isSubDirectory (parent, child) {
if (!parent) return false
if (parent === child) return true
const relative = pathModule.relative(parent, child)
return !!relative && relative.split(pathModule.sep)[0] !== '..'
}
resolveDirectory (path, callback) {
super.resolveDirectory(path, (error, files) => {
if (error) return callback(error)

Loading…
Cancel
Save