Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/remix-ide-e2e/src/tests/fileExplorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ module.exports = {
.waitForElementVisible('*[key="browser/fileExplorer.test.js"]')
.waitForElementVisible('*[key="browser/generalSettings.test.js"]')
.end()
},
},

tearDown: sauce
}

18 changes: 17 additions & 1 deletion apps/remix-ide-e2e/src/tests/fileManager_api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ module.exports = {
.addFile('removeFile.js', { content: executeRemove })
.executeScript(`remix.exeCurrent()`)
.pause(2000)
.waitForElementNotPresent('[data-id="treeViewLibrowser/old_contract.sol"]')
.waitForElementNotPresent('[data-id="treeViewLibrowser/old_contract.sol"]')
},

'Should execute `remove` api from file manager external api on a folder': function (browser: NightwatchBrowser) {
browser
.addFile('test_jsRemoveFolder.js', { content: executeRemoveOnFolder })
.executeScript('remix.exeCurrent()')
.pause(2000)
.waitForElementNotPresent('*[key="browser/tests"]')
.end()
},

Expand Down Expand Up @@ -189,3 +197,11 @@ const executeRemove = `

run()
`

const executeRemoveOnFolder = `(async () => {
try {
await remix.call('fileManager', 'remove', 'browser')
} catch (e) {
console.log(e.message)
}
})()`
3 changes: 2 additions & 1 deletion apps/remix-ide/src/app/files/fileProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class FileProvider {
const items = window.remixFileSystem.readdirSync(path)
if (items.length !== 0) {
items.forEach((item, index) => {
const curPath = `${path}/${item}`
const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}`
if (window.remixFileSystem.statSync(curPath).isDirectory()) { // delete folder
this.remove(curPath)
} else { // delete file
Expand Down Expand Up @@ -238,6 +238,7 @@ class FileProvider {

removePrefix (path) {
path = path.indexOf(this.type) === 0 ? path.replace(this.type, '') : path
if (path === '') return '/'
return path
}

Expand Down
1 change: 1 addition & 0 deletions apps/remix-ide/src/app/files/remixDProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ module.exports = class RemixDProvider {
removePrefix (path) {
path = path.indexOf(this.type) === 0 ? path.replace(this.type, '') : path
if (path[0] === '/') return path.substring(1)
if (path === '') return '/'
return path
}

Expand Down
5 changes: 2 additions & 3 deletions libs/remixd/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import * as pathModule from 'path'
*/
function absolutePath (path: string, sharedFolder:string): string {
path = normalizePath(path)
if (path.indexOf(sharedFolder) !== 0) {
path = pathModule.resolve(sharedFolder, path)
}
path = pathModule.resolve(sharedFolder, path)
return path
}

Expand All @@ -34,6 +32,7 @@ function normalizePath (path: string): string {
if (process.platform === 'win32') {
return path.replace(/\\/g, '/')
}
if (path === '/') path = './'
return path
}

Expand Down